//@version=5
strategy("RSI Divergence", overlay=true,
default_qty_type=strategy.percent_of_equity, default_qty_value=10)
rsiLen = input.int(14, "RSI Period")
pivotLb = input.int(5, "Pivot Lookback")
rsiV = ta.rsi(close, rsiLen)
atrV = ta.atr(14)
// Pivotlar
ph = ta.pivothigh(high, pivotLb, pivotLb)
pl = ta.pivotlow(low, pivotLb, pivotLb)
phRsi = ta.pivothigh(rsiV, pivotLb, pivotLb)
plRsi = ta.pivotlow(rsiV, pivotLb, pivotLb)
var float prevPL = na, var float prevPLRsi = na
var float prevPH = na, var float prevPHRsi = na
var float currPL = na, var float currPLRsi = na
var float currPH = na, var float currPHRsi = na
if not na(pl)
prevPL := currPL
prevPLRsi := currPLRsi
currPL := pl
currPLRsi := rsiV[pivotLb]
if not na(ph)
prevPH := currPH
prevPHRsi := currPHRsi
currPH := ph
currPHRsi := rsiV[pivotLb]
bullDiv = not na(prevPL) and not na(currPL) and currPL < prevPL and currPLRsi > prevPLRsi and currPLRsi < 40
bearDiv = not na(prevPH) and not na(currPH) and currPH > prevPH and currPHRsi < prevPHRsi and currPHRsi > 60
if bullDiv and strategy.position_size == 0
sl = currPL - 0.3 * atrV
risk = close - sl
if risk > 0
strategy.entry("Div L", strategy.long)
strategy.exit("X", "Div L", stop=sl, limit=close + risk * 3)
if bearDiv and strategy.position_size == 0
sl = currPH + 0.3 * atrV
risk = sl - close
if risk > 0
strategy.entry("Div S", strategy.short)
strategy.exit("X", "Div S", stop=sl, limit=close - risk * 3)
plotshape(bullDiv, "Bull Div", shape.triangleup, location.belowbar, color.lime, size=size.normal)
plotshape(bearDiv, "Bear Div", shape.triangledown, location.abovebar, color.red, size=size.normal)
Overview
A bullish divergence triggers a long entry when price forms a lower low while RSI forms a higher low below 40. A bearish divergence triggers a short entry when price forms a higher high while RSI forms a lower high above 60. Positions are protected by ATR-adjusted stop losses based on pivot levels, and exits target a 1:3 risk-to-reward ratio. Shapes are plotted directly on the main chart when signals occur.
RSI divergence detection using price and oscillator pivots
ATR-adjusted stop loss placement based on pivot levels
Fixed 1:3 risk-to-reward ratio take profit targets
Visual signal shapes for bullish and bearish divergences
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
RSI Period
int
14
rsiLen
Pivot Lookback
int
5
pivotLb
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 overlays a Cipher B style WaveTrend study on the price chart and is titled for Ethereum buy alerts aimed at 3Commas. It calculates a WaveTrend channel and a short moving average, and can mark buy, sell, gold, and divergence dots. Settings change
This overlay strategy combines a Cipher B WaveTrend oscillator with two optional moving averages on the price chart. It exposes WaveTrend channel and average lengths, overbought and oversold levels, buy, sell and gold dots, and regular or hidden divergence mar
Divergenced A002 is a momentum divergence strategy designed to identify entry opportunities using Squeeze Momentum Indicator shifts alongside price action. It enters long when momentum reaches higher lows during lower price lows and enters short on opposite di
This strategy executes long positions by combining a 200-period EMA trend filter, Stochastic RSI oversold crosses, and Williams Alligator retracements, supplemented by RSI divergence detection. It triggers long entries when the price trades above the 200 EMA w
Divergence Strategy scans multiple technical oscillators to detect regular and hidden divergences against price action. It evaluates customizable indicators including MACD, RSI, Stochastic, CCI, Momentum, OBV, and Money Flow Index to trigger strategy entries o
This strategy enters long when the MACD line crosses above its signal line and short when it crosses below. Optional filters require the histogram to exceed a threshold, price to sit on the matching side of a simple moving average, and a simplified three-bar d