RSI(2) pullback with market filter
The classic short-term pullback: buy a stock in a long-term uptrend when RSI(2) shows a sharp dip, but only while the market itself is above its 200-day average, and sell on the bounce or after ten days. It is the language reference’s own example.
Strategies · rsi2_pullback.rvw
language 1
strategy "RSI(2) pullback with market filter" {
universe members("SYN500") // index label from the user's data
regime close("SYNSPY") > sma(close("SYNSPY"), 200) // cross-symbol filter
rsi2 rsi(close, 2)
enter long when regime and close > sma(close, 200) and rsi2 < rsi_entry
rank by -rsi2
size 10% of equity, max 10 positions
exit when rsi2 > 70 or bars_held >= 10
fill next_open
param rsi_entry = 10 in 5..20 step 5
}
Functions it uses
Try it
File ▸ New Script from Example adds it to a project. The examples read the sample’s index label, SYN500, and market ETF, SYNSPY; when your data has neither, a sheet asks what to read instead, one of your index labels (or every stock and ETF) and a ticker, so the example runs on your data as it is.
Before you trust what it does on your data, see whether it’s luck: Is this result luck?