//@version=5
strategy("Stochastic RSI Crossover - Eterna MCP",
shorttitle="Stoch RSI",
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)
stochLength = input.int(14, "Stochastic Length", minval=1)
smoothK = input.int(3, "K Smoothing", minval=1)
smoothD = input.int(3, "D Smoothing", minval=1)
upperLevel = input.int(80, "Overbought Level", minval=50, maxval=100)
lowerLevel = input.int(20, "Oversold Level", minval=0, maxval=50)
leverageSize = input.float(5.0, "Leverage", minval=1, maxval=100)
positionSize = input.float(0.01, "Position Size", minval=0.001, maxval=1)
// ============================================
// STOCHASTIC RSI CALCULATION
// ============================================
rsi = ta.rsi(close, rsiLength)
stochRSI = ta.stoch(rsi, rsi, rsi, stochLength)
k = ta.sma(stochRSI, smoothK)
d = ta.sma(k, smoothD)
// ============================================
// SIGNAL GENERATION
// ============================================
// Bullish: K crosses above D in oversold zone
bullishCross = ta.crossover(k, d) and k < lowerLevel
// Bearish: K crosses below D in overbought zone
bearishCross = ta.crossunder(k, d) and k > upperLevel
// Additional confirmation: momentum direction
bullishMomentum = k > k[1] and d > d[1]
bearishMomentum = k < k[1] and d < d[1]
// ============================================
// STRATEGY LOGIC
// ============================================
if bullishCross 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 bearishCross 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 conditions
if bearishCross and strategy.position_size > 0
strategy.close("Long")
if bullishCross and strategy.position_size < 0
strategy.close("Short")
// ============================================
// PLOTTING
// ============================================
plot(k, "K", color=color.blue, linewidth=2)
plot(d, "D", color=color.orange, linewidth=2)
hline(upperLevel, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(lowerLevel, "Oversold", color=color.green, linestyle=hline.style_dashed)
hline(50, "Midline", color=color.gray, linestyle=hline.style_dotted)
bgcolor(bullishCross ? color.new(color.green, 90) : na)
bgcolor(bearishCross ? color.new(color.red, 90) : na)
plotshape(bullishCross, "Buy Signal", shape.triangleup, location.bottom, color.green, size=size.small)
plotshape(bearishCross, "Sell Signal", shape.triangledown, location.top, color.red, size=size.small)
Overview
Stochastic RSI Crossover - Eterna MCP computes RSI of close, then a stochastic of that RSI, and smooths the result into K and D lines. It enters long when K crosses above D below the oversold level and short when K crosses below D above the overbought level, only from a flat position. Opposite crosses close the open trade. There is no stop loss or take profit. RSI, stochastic, and smoothing lengths, threshold levels, leverage, and position size are adjustable. Alerts include size and leverage for external order routing.
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
Stochastic Length
int
14
stochLength
K Smoothing
int
3
smoothK
D Smoothing
int
3
smoothD
Overbought Level
int
80
upperLevel
Oversold Level
int
20
lowerLevel
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
This strategy combines the ATR-banded Q-Trend indicator with the Klinger Volume Oscillator (KVO) to execute confluence trades. It enters long when a Q-Trend buy trigger aligns with a positive KVO value and a bullish candle confirmation, taking short trades und
This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr
This strategy estimates price behavior using ordinary least squares regression between higher-timeframe data and a generated dataset, smoothed by a Karobein oscillator. It enters long positions when the oscillator turns upward and short positions when it turns
This strategy executes mean-reversion trades based on Bollinger Bands and the Stochastic Oscillator. Long orders trigger when price dips below the lower band alongside a bullish Stochastic crossover, with an optional oversold threshold. Short orders execute on
This strategy calculates a 20-period Relative Strength Index (RSI) and generates entry orders based on crossovers and crossunders of the 50 level. When RSI crosses above 50, it places a long stop entry at the current high price with a custom alert message. Whe