OPEN-SOURCE SCRIPT
Trend + RSI + Volume

//version=5
strategy("SPY Trend RSI Volume Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === Inputs ===
emaFastLen = input.int(20, title="Fast EMA")
emaSlowLen = input.int(50, title="Slow EMA")
rsiLen = input.int(14, title="RSI Period")
rsiLongThresh = input.int(55, title="RSI Threshold for Long")
rsiShortThresh = input.int(45, title="RSI Threshold for Short")
volumeMultiplier = input.float(1.5, title="Volume Multiplier")
atrLen = input.int(14, title="ATR Length")
riskReward = input.float(2.0, title="Risk-Reward Ratio")
atrMult = input.float(1.5, title="ATR Multiplier")
// === Indicators ===
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)
rsi = ta.rsi(close, rsiLen)
avgVolume = ta.sma(volume, 20)
atr = ta.atr(atrLen)
// === Conditions ===
// Trend
isBullish = emaFast > emaSlow
isBearish = emaFast < emaSlow
// Volume
volSpike = volume > avgVolume * volumeMultiplier
// Entry conditions
longCondition = isBullish and rsi > rsiLongThresh and volSpike and close > emaFast
shortCondition = isBearish and rsi < rsiShortThresh and volSpike and close < emaFast
// === Entries ===
if (longCondition)
stopLoss = close - atr * atrMult
takeProfit = close + (close - stopLoss) * riskReward
strategy.entry("Long", strategy.long)
strategy.exit("TP/SL Long", from_entry="Long", stop=stopLoss, limit=takeProfit)
if (shortCondition)
stopLoss = close + atr * atrMult
takeProfit = close - (stopLoss - close) * riskReward
strategy.entry("Short", strategy.short)
strategy.exit("TP/SL Short", from_entry="Short", stop=stopLoss, limit=takeProfit)
// === Plotting ===
plot(emaFast, title="EMA 20", color=color.orange)
plot(emaSlow, title="EMA 50", color=color.blue)
strategy("SPY Trend RSI Volume Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === Inputs ===
emaFastLen = input.int(20, title="Fast EMA")
emaSlowLen = input.int(50, title="Slow EMA")
rsiLen = input.int(14, title="RSI Period")
rsiLongThresh = input.int(55, title="RSI Threshold for Long")
rsiShortThresh = input.int(45, title="RSI Threshold for Short")
volumeMultiplier = input.float(1.5, title="Volume Multiplier")
atrLen = input.int(14, title="ATR Length")
riskReward = input.float(2.0, title="Risk-Reward Ratio")
atrMult = input.float(1.5, title="ATR Multiplier")
// === Indicators ===
emaFast = ta.ema(close, emaFastLen)
emaSlow = ta.ema(close, emaSlowLen)
rsi = ta.rsi(close, rsiLen)
avgVolume = ta.sma(volume, 20)
atr = ta.atr(atrLen)
// === Conditions ===
// Trend
isBullish = emaFast > emaSlow
isBearish = emaFast < emaSlow
// Volume
volSpike = volume > avgVolume * volumeMultiplier
// Entry conditions
longCondition = isBullish and rsi > rsiLongThresh and volSpike and close > emaFast
shortCondition = isBearish and rsi < rsiShortThresh and volSpike and close < emaFast
// === Entries ===
if (longCondition)
stopLoss = close - atr * atrMult
takeProfit = close + (close - stopLoss) * riskReward
strategy.entry("Long", strategy.long)
strategy.exit("TP/SL Long", from_entry="Long", stop=stopLoss, limit=takeProfit)
if (shortCondition)
stopLoss = close + atr * atrMult
takeProfit = close - (stopLoss - close) * riskReward
strategy.entry("Short", strategy.short)
strategy.exit("TP/SL Short", from_entry="Short", stop=stopLoss, limit=takeProfit)
// === Plotting ===
plot(emaFast, title="EMA 20", color=color.orange)
plot(emaSlow, title="EMA 50", color=color.blue)
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
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.