Strategy · Pine Script v5 · Own pane

Stochastic RSI Crossover - Eterna MCP

by EternaHybridExchange

This strategy plots a Stochastic RSI oscillator in a separate pane.

View on GitHub

GitHub stars9on the repository
Pine versionv5runs as is
Lines of code73
Settings8inputs
LicenceMIT
Last update7 months ago12 Mar 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 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

73 lines of Pine Script v5 from strategies/momentum/stoch_rsi_crossover.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

stoch_rsi_crossover.pine
//@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.

Details

Published by

EternaHybridExchange on GitHub

Type

Strategy, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingautomated-tradingbacktestingbybitcrypto-tradingeternamcppine-scripttrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI Lengthint14rsiLength
Stochastic Lengthint14stochLength
K Smoothingint3smoothK
D Smoothingint3smoothD
Overbought Levelint80upperLevel
Oversold Levelint20lowerLevel
Leveragefloat5.0leverageSize
Position Sizefloat0.01positionSize
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.

Similar Pine Scripts

330 stars

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

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]

Q-Trend + KVO Strategy

by TradersPost
218 stars

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

Strategy v6 TrendVolume
Updated 3 months ago · None stated GitHub repository of Q-Trend + KVO Strategy

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

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

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)
114 stars

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

Strategy v4 Oscillators & momentumAI / machine learning Repaints

2xTP, SL to Entry

by hasnocool
106 stars

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

Strategy v5 Mean reversionOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 2xTP, SL to Entry
65 stars

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

Strategy v4 Oscillators & momentum
Updated 4 days ago · GPL-3.0 GitHub repository of Strategy Using Alert Message

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers