OPEN-SOURCE SCRIPT

Мой скрипт

146
//version=5
indicator("Momentum Reversal Zones Strategy", overlay=true)

// === INPUTS ===
rsiLength = input.int(14, title="RSI Length")
stochK = input.int(14, title="Stochastic %K")
stochD = input.int(3, title="Stochastic %D")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")

// === RSI ===
rsi = ta.rsi(close, rsiLength)

// === Stochastic Oscillator ===
k = ta.stoch(close, high, low, stochK)
d = ta.sma(k, stochD)

// === Buy Signal Conditions ===
rsiBuy = rsi < rsiOversold
stochBuy = ta.crossover(k, d) and k < 20
buySignal = rsiBuy and stochBuy

// === Sell Signal Conditions ===
rsiSell = rsi > rsiOverbought
stochSell = ta.crossunder(k, d) and k > 80
sellSignal = rsiSell and stochSell

// === Plot signals ===
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.arrowup, size=size.small, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.arrowdown, size=size.small, text="SELL")

// === Alerts ===
alertcondition(buySignal, title="Buy Alert", message="Buy Signal: RSI < 30 and Stochastic Bullish Crossover")
alertcondition(sellSignal, title="Sell Alert", message="Sell Signal: RSI > 70 and Stochastic Bearish Crossover")

// === Show RSI and Stochastic in separate panel ===
plot(rsi, title="RSI", color=color.blue, linewidth=1, display=display.none)
hline(rsiOverbought, "Overbought", color=color.red, linestyle=hline.style_dotted, display=display.none)
hline(rsiOversold, "Oversold", color=color.green, linestyle=hline.style_dotted, display=display.none)

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.