This long-only strategy buys short-term oversold dips only inside a strong uptrend: price above a rising 200-period SMA and within a set percentage of its one-year high.
1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.
Overview
Entry needs a two-period RSI below a threshold, then an up-close, and volatility below an ATR percentile limit. It exits when price closes above a short SMA, an ATR stop is hit, the regime fails or a maximum holding time ends. It holds one position, sized as a share of equity.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Bull-regime SMA length
int
200
regimeLen
Require rising regime SMA
bool
true
useSlope
Regime slope lookback
int
20
slopeLen
Uptrend high lookback (bars)
int
252
hiLen
Only buy within % of that high
float
15
hiTolPct
RSI length
int
2
rsiLen
Buy when RSI below
float
10
rsiBuy
Require up-close reversal confirmation
bool
true
useReversal
Only buy in calm volatility
bool
true
useCalm
ATR percentile lookback
int
100
volLen
Skip entries above ATR percentile
float
70
maxVolPct
Reversion exit SMA length
int
5
exitMaLen
Show all 17 settings
Setting
Type
Default
Variable
Use protective ATR stop
bool
true
useAtrStop
ATR length
int
14
atrLen
ATR stop multiple
float
2.5
atrStopMult
Max bars in trade
int
15
maxHold
Show regime / exit moving averages
bool
true
showMas
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This strategy calculates Bollinger Bands and Aroon oscillator values to identify mean-reversion opportunities. It enters a long position using full equity when the closing price crosses below the lower Bollinger Band while Aroon Up remains above a user-specifi
Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish
The Chained Linear Regression Reversal Strategy plots linear regression channels with upper and lower standard deviation bands directly on the price chart across a user-defined time window. When price breaks out of the static channel for a confirmed number of
Inspired by Linda Raschke's strategy for T-note futures, this script identifies extended trends where price remains on one side of a 5-period SMA for more than eight consecutive bars. It enters long on the first pullback below the SMA following an eight-bar bu
This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po
This strategy identifies long entry opportunities based on short-term price pullbacks below a major trend filter. It enters long when three consecutive lower closes occur below the 200-period simple moving average, followed by the current bar closing back abov