OPEN-SOURCE SCRIPT

My script

67
//version=5
strategy("15-Min EMA + RSI Pullback Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// === INPUTS ===
emaShort = input.int(9, title="EMA Short")
emaLong = input.int(21, title="EMA Long")
rsiPeriod = input.int(14, title="RSI Period")
rsiBuyThresh = input.int(40, title="RSI Buy Threshold")
rsiSellThresh = input.int(60, title="RSI Sell Threshold")
sl_pct = input.float(1.0, title="Stop Loss %", minval=0.1)
tp_pct = input.float(2.0, title="Take Profit %", minval=0.1)

// === CALCULATIONS ===
emaFast = ta.ema(close, emaShort)
emaSlow = ta.ema(close, emaLong)
rsi = ta.rsi(close, rsiPeriod)

// === CONDITIONS ===
// Long setup
bullTrend = emaFast > emaSlow
pullbackLong = close > emaSlow and close < emaFast
rsiLongCond = rsi > rsiBuyThresh
bullSignal = bullTrend and pullbackLong and rsiLongCond

// Short setup
bearTrend = emaFast < emaSlow
pullbackShort = close < emaSlow and close > emaFast
rsiShortCond = rsi < rsiSellThresh
bearSignal = bearTrend and pullbackShort and rsiShortCond

// === ENTRIES ===
if bullSignal
strategy.entry("Long", strategy.long)
strategy.exit("TP/SL Long", from_entry="Long", stop=close * (1 - sl_pct / 100), limit=close * (1 + tp_pct / 100))

if bearSignal
strategy.entry("Short", strategy.short)
strategy.exit("TP/SL Short", from_entry="Short", stop=close * (1 + sl_pct / 100), limit=close * (1 - tp_pct / 100))

// === PLOT INDICATORS ===
plot(emaFast, color=color.orange, title="EMA 9")
plot(emaSlow, color=color.blue, title="EMA 21")

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.