EQUITYFRAME
EQUITYFRAME switches a ProScreener to price data from another security in the same market, enabling relative strength and benchmark comparison screens.
Syntax
EQUITYFRAME("market", "ticker")EQUITYFRAME(default)Parameters
| Name | Type | Description |
|---|---|---|
market | string | Name of the market or exchange the reference security trades on, for example "NASDAQ". |
ticker | string | Symbol of the reference security, for example "AMZN". Must match the platform's symbol exactly. |
default | keyword | Restores the data context to the instrument currently being scanned. |
How it works
A ProScreener normally evaluates every expression against the instrument currently being scanned. After a call to EQUITYFRAME("market", "ticker"), constants such as close, open, high, low, and volume on the following lines refer to the named reference security instead. The switch stays in effect until EQUITYFRAME(default) returns the context to the scanned instrument.
The typical pattern is a three-step sandwich. First, capture values from the scanned instrument into variables. Second, switch to the reference security and capture its values. Third, switch back with EQUITYFRAME(default) and combine both sets of variables into a ratio, spread, or comparison that drives the SCREENER condition.
The instruction only supports securities from the same market as the scanned list. Cross-market references are not accepted, so a screener running on one exchange cannot pull data from an index or stock listed elsewhere. Variables keep the values they were assigned regardless of which context was active at assignment time, which is what makes the sandwich pattern work.
Examples
Example 1, Relative strength against a reference stock (ProScreener)
// Daily relative strength of each scanned stock versus AMZN
TIMEFRAME(daily)
CloseVal = Close
EQUITYFRAME("NASDAQ", "AMZN")
CloseInd = Close
EQUITYFRAME(default)
Ratio = (CloseVal / CloseInd) * 100
RelativeStrength = (Ratio - Ratio[1]) * 100
SCREENER(RelativeStrength AS "RelativeStrength")Each scanned stock's close is divided by the reference security's close, and the change in that ratio is displayed as a relative strength column. This is the canonical example from the official reference.
Example 2, Filtering for outperformance over 20 bars (ProScreener)
// Performance of the scanned stock over the last 20 bars
stockPerf = (close / close[20] - 1) * 100
// Performance of a reference security from the same market
EQUITYFRAME("NASDAQ", "AAPL")
refPerf = (close / close[20] - 1) * 100
EQUITYFRAME(default)
outperform = stockPerf > refPerf
SCREENER[outperform](stockPerf - refPerf AS "Excess perf")Only stocks that beat the reference security over 20 bars pass the filter, and the margin of outperformance is shown as a column.
Example 3, Rising ratio versus a sector bellwether (ProScreener)
// Ratio between the scanned instrument and a bellwether stock
scanClose = close
EQUITYFRAME("NASDAQ", "MSFT")
benchClose = close
EQUITYFRAME(default)
ratio = scanClose / benchClose
risingRatio = ratio > ratio[10]
SCREENER[risingRatio](ratio AS "Ratio")The screener returns instruments whose price ratio against the bellwether has risen over the last 10 bars, a simple momentum-of-relative-strength scan.
Common errors and gotchas
- Forgetting EQUITYFRAME(default). Every line after a switch reads the reference security. Omitting the reset means the
SCREENERcondition itself is evaluated on the reference data, so every scanned instrument returns the same result. Always close the sandwich. - Cross-market references. Both securities must belong to the same market. Pointing a screener at a ticker from another exchange fails, even if the symbol exists there. Choose a benchmark listed on the market being scanned.
- Ticker and market spelling. The strings must match the platform's naming exactly. A misspelled ticker or market name does not fall back to a close match, it simply fails to resolve the security.
- Capturing before switching. Values from the scanned instrument must be stored in variables before the switch. Reading
closeafterEQUITYFRAMEreturns the reference security's close, a frequent source of ratios that compare a security to itself.
Related instructions
SCREENER, defines the filter condition and result column of a screener.TIMEFRAME (PS), sets the timeframe used by subsequent screener code.Close, the closing price of the active data context.ROC, rate of change, a common performance measure for comparisons.Variation, percentage change of the current bar.Average, moving average, useful for smoothing ratios.NUMBERFORMAT, abbreviates large numeric values in a screener column.EstimatedVolume, projected final volume of the current bar in ProScreener.
