SCREENER
SCREENER in ProScreener returns the instruments that match filter conditions, with an optional sort criterion. Syntax, examples, and common errors explained.
Syntax
SCREENER[conditions]SCREENER[conditions](criterion AS "Column name")Parameters
| Name | Type | Default | Description |
|---|---|---|---|
conditions | boolean expression | required | One or more conditions an instrument must satisfy to appear in the results. Combine with AND, OR, and parentheses. |
criterion | numeric expression | none | Optional value displayed next to each matching instrument and used to sort the result list. |
AS "label" | string | expression text | Optional column header for the criterion in the results table. |
How it works
A ProScreener program runs once per instrument in the selected list. All the code above the SCREENER call computes indicator values and boolean flags for that instrument; the SCREENER call then decides whether the instrument makes it into the results. When conditions evaluates to true on the most recent bar, the instrument is listed.
The optional criterion gives each match a numeric score. ProRealTime shows the score in a dedicated column and sorts the result list by it, which is how a screener ranks candidates rather than just filtering them. The AS "label" suffix renames that column.
A screener contains exactly one SCREENER instruction, and it replaces RETURN as the program's terminal statement. Conditions built on other timeframes are declared with the ProScreener variant of TIMEFRAME before the flags are computed, as in the first example.
Examples
Example 1, Multi-timeframe MACD and Stochastic filter (ProScreener)
REM Flag 1: weekly MACD below zero but rising
TIMEFRAME(weekly)
MyMACD = MACD[12,26,9](Close)
c1 = MyMACD < 0 AND MyMACD > MyMACD[1]
REM Flag 2: daily Stochastic under 30
TIMEFRAME(daily)
MySTO = Stochastic[14,3](Close)
c2 = MySTO < 30
REM Reference level: yesterday's high
MyStop = High[1]
REM Score: distance from yesterday's high, in percent
Criteria = (Close / MyStop - 1) * 100
REM Flag 3: price no more than 5 percent above that high
c3 = Criteria < 5
SCREENER[c1 AND c2 AND c3](Criteria)Three flags are combined in a single SCREENER call, and the matches are ranked by their distance from the previous day's high. This is the example from the official reference.
Example 2, Oversold RSI with a liquidity filter (ProScreener)
// Momentum condition: 14-period RSI in oversold territory
myRSI = RSI[14](close)
oversold = myRSI < 30
// Liquidity condition: 20-bar average volume above a floor
liquid = Average[20](volume) > 500000
SCREENER[oversold AND liquid](myRSI AS "RSI 14")Only instruments that are both oversold and actively traded are listed, sorted by their RSI value under a custom column header.
Example 3, Proximity to the 52-week high (ProScreener)
// Highest weekly high over the past 52 weeks
TIMEFRAME(weekly)
yearHigh = Highest[52](high)
// Compare the daily close against that level
TIMEFRAME(daily)
distance = (close / yearHigh - 1) * 100
// Keep instruments within 3 percent of the high
near = distance > -3
SCREENER[near](distance AS "Pct vs 52w high")The screener surfaces instruments trading near their 52-week high and ranks them by how close they are, expressed in percent.
Common errors and gotchas
- More than one SCREENER call. A program accepts exactly one SCREENER instruction, placed at the end. Splitting output across two calls does not compile; merge the conditions with
ANDorORinstead. - RETURN in a screener. ProScreener has no RETURN. Code ported from an indicator must replace its RETURN line with a SCREENER call, moving plotted values into the criterion slot if they should stay visible.
- Non-numeric criterion. The sorting criterion must reduce to a number. Passing a boolean flag technically works as 0 or 1 but produces a meaningless ranking; compute an explicit score instead.
- Wrong scope. SCREENER pasted into indicator or strategy code fails to compile, and strategy instructions such as BUY or SELL fail inside a screener. Signal logic transfers between the languages, output and order instructions do not.
Related instructions
TIMEFRAME (PS), the ProScreener variant of TIMEFRAME for multi-timeframe conditions.EQUITYFRAME, restricts which instruments a screener scans.EstimatedVolume, projected end-of-period volume, useful in liquidity filters.NUMBERFORMAT, formats the criterion column as a number.PERCENTFORMAT, formats the criterion column as a percentage.STRINGFORMAT, maps criterion values to text labels.DATEFORMAT, formats the criterion column as a date.
