//@version=5
strategy("RSI Divergence Strategy - Eterna MCP",
shorttitle="RSI Div",
overlay=false,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
initial_capital=1000)
// ============================================
// PARAMETERS
// ============================================
rsiLength = input.int(14, "RSI Length", minval=1)
rsiOverbought = input.int(70, "RSI Overbought", minval=50, maxval=100)
rsiOversold = input.int(30, "RSI Oversold", minval=0, maxval=50)
pivotLookback = input.int(5, "Pivot Lookback", minval=1)
leverageSize = input.float(5.0, "Leverage", minval=1, maxval=100)
positionSize = input.float(0.01, "Position Size", minval=0.001, maxval=1)
// ============================================
// RSI CALCULATION
// ============================================
rsi = ta.rsi(close, rsiLength)
// ============================================
// DIVERGENCE DETECTION
// ============================================
// Pivot highs and lows
pivotHigh = ta.pivothigh(rsi, pivotLookback, pivotLookback)
pivotLow = ta.pivotlow(rsi, pivotLookback, pivotLookback)
pricePivotHigh = ta.pivothigh(high, pivotLookback, pivotLookback)
pricePivotLow = ta.pivotlow(low, pivotLookback, pivotLookback)
// Store pivot points
var float lastRsiHigh = na
var float lastPriceHigh = na
var float lastRsiLow = na
var float lastPriceLow = na
if not na(pivotHigh)
lastRsiHigh := pivotHigh
lastPriceHigh := pricePivotHigh
if not na(pivotLow)
lastRsiLow := pivotLow
lastPriceLow := pricePivotLow
// Bullish divergence: price makes lower low, RSI makes higher low
bullishDiv = not na(lastRsiLow) and not na(lastPriceLow) and
low < lastPriceLow and rsi > lastRsiLow and
rsi < rsiOversold
// Bearish divergence: price makes higher high, RSI makes lower high
bearishDiv = not na(lastRsiHigh) and not na(lastPriceHigh) and
high > lastPriceHigh and rsi < lastRsiHigh and
rsi > rsiOverbought
// ============================================
// STRATEGY LOGIC
// ============================================
if bullishDiv and strategy.position_size == 0
strategy.entry("Long", strategy.long)
alert('{"action":"buy","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)
if bearishDiv and strategy.position_size == 0
strategy.entry("Short", strategy.short)
alert('{"action":"sell","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)
// Exit on opposite signal
if bearishDiv and strategy.position_size > 0
strategy.close("Long")
if bullishDiv and strategy.position_size < 0
strategy.close("Short")
// ============================================
// PLOTTING
// ============================================
plot(rsi, "RSI", color=color.blue, linewidth=2)
hline(rsiOverbought, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(rsiOversold, "Oversold", color=color.green, linestyle=hline.style_dashed)
hline(50, "Midline", color=color.gray, linestyle=hline.style_dotted)
plotshape(bullishDiv, "Bullish Divergence", shape.triangleup, location.bottom, color.green, size=size.small)
plotshape(bearishDiv, "Bearish Divergence", shape.triangledown, location.top, color.red, size=size.small)
Overview
RSI Divergence Strategy - Eterna MCP plots the RSI oscillator, overbought and oversold threshold lines, and divergence markers in a separate pane. A long position enters when a bullish divergence forms in oversold conditions, while a short position enters on a bearish divergence in overbought conditions. Exits occur when an opposing divergence signal appears. Key settings allow adjustment of RSI parameters, pivot lookback periods, leverage, and position size for automated webhook alerts. The strategy lacks a stop loss.
RSI oscillator with overbought and oversold threshold lines
Bullish and bearish divergence detection using pivot points
Opposing divergence signal exits for active positions
Webhook alert payloads with leverage and position size parameters
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
RSI Length
int
14
rsiLength
RSI Overbought
int
70
rsiOverbought
RSI Oversold
int
30
rsiOversold
Pivot Lookback
int
5
pivotLookback
Leverage
float
5.0
leverageSize
Position Size
float
0.01
positionSize
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.
MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra
The Stochastic Divergence Strategy calculates the Stochastic oscillator (%K and %D) to identify regular bullish and bearish divergence patterns against price pivots. It plots the oscillator and divergence lines in a separate indicator pane. Entries trigger on
This strategy calculates regular and hidden divergences across selectable momentum oscillators, including RSI, CCI, and MFI, and plots volatility-based divergence zones. It displays oscillator dynamics in a separate pane while projecting support and resistance
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