1Copy the scriptPress Copy script above, or the copy button on the code below.
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
107 lines of Pine Script v5 from 14_MACD_Divergence/14_MACD_Divergence.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
MACD Divergence - Reversal Hunter generates buy signals on bullish divergences and sell signals on bearish divergences, with optional RSI filter for overbought or oversold confirmation. Entries use a risk-reward ratio and ATR-based stop loss. The strategy overlays signals directly on the price chart for reversal or continuation trades.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
MACD Fast
int
12
macdFast
MACD Slow
int
26
macdSlow
MACD Signal
int
9
macdSignal
Pivot Lookback
int
5
pivotLookback
Pivot Look Forward
int
2
pivotLookfwd
Trade Regular Divergence
bool
true
useRegular
Trade Hidden Divergence
bool
true
useHidden
RSI Confirmation Length
int
14
rsiLength
RSI Overbought
float
70
rsiOB
RSI Oversold
float
30
rsiOS
Use RSI Extreme Filter
bool
true
useRSIFilter
ATR Length
int
14
atrLength
Show all 14 settings
Setting
Type
Default
Variable
ATR Multiplier for SL
float
2.0
atrMult
Risk:Reward Ratio
float
2.0
rrRatio
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.
The Stock and NQ Futures Convergence Strategy identifies trading opportunities by comparing the Relative Strength Index of the active chart stock against NQ futures. It enters a long position when NQ RSI rises above the upper threshold while the stock RSI stay
This strategy evaluates market conditions using a combination of WaveTrend, RSI, Stochastic RSI, and a custom Money Flow Index calculation inspired by VuManChu. It enters long positions when multiple oscillators hit oversold thresholds and generate an upward c
This strategy calculates the Z-score divergence of return spreads between two forex assets such as EURUSD and GBPUSD. It enters long positions when the Z-score falls below the entry threshold with confirmed uptrend from EMA, RSI and MACD filters plus sufficien
Alert BB + RSI [Alorse] is a multi-symbol mean-reversion strategy designed for cryptocurrency trading. It evaluates Bollinger Bands and the Relative Strength Index (RSI) across up to 20 user-defined ticker symbols simultaneously. The strategy enters long posit
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
This strategy draws on the price chart and combines Stochastic RSI, the Money Flow Index, and an exponential moving average to open long or short trades. Longs use the lower oscillator thresholds and shorts use the upper ones, with direction limited to longs,