OPEN-SOURCE SCRIPT
Valtoro Adaptive Momentum

//version=5
strategy("Valtoro Adaptive Momentum", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === Inputs ===
lengthFast = input.int(14, title="Fast EMA")
lengthSlow = input.int(28, title="Slow EMA")
rsiPeriod = input.int(14, title="RSI Period")
atrPeriod = input.int(14, title="ATR Period")
riskMultiplier = input.float(1.5, title="Volatility Threshold Multiplier", step=0.1)
rsiOB = input.int(70, title="RSI Overbought")
rsiOS = input.int(30, title="RSI Oversold")
// === Indicators ===
fastEMA = ta.ema(close, lengthFast)
slowEMA = ta.ema(close, lengthSlow)
rsi = ta.rsi(close, rsiPeriod)
atr = ta.atr(atrPeriod)
avgATR = ta.sma(atr, atrPeriod)
// === Conditions ===
longCond = ta.crossover(fastEMA, slowEMA) and rsi < rsiOB and atr > avgATR * riskMultiplier
shortCond = ta.crossunder(fastEMA, slowEMA) and rsi > rsiOS and atr > avgATR * riskMultiplier
// === Risk Management ===
longSL = close * 0.98 // 2% Stop Loss
longTP = close * 1.05 // 5% Take Profit
shortSL = close * 1.02
shortTP = close * 0.95
// === Strategy Entries and Exits ===
if (longCond)
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", from_entry="Long", stop=longSL, limit=longTP)
if (shortCond)
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL, limit=shortTP)
// === Visuals ===
plot(fastEMA, title="Fast EMA", color=color.blue)
plot(slowEMA, title="Slow EMA", color=color.red)
hline(rsiOB, "RSI Overbought", color=color.red)
hline(rsiOS, "RSI Oversold", color=color.green)
strategy("Valtoro Adaptive Momentum", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === Inputs ===
lengthFast = input.int(14, title="Fast EMA")
lengthSlow = input.int(28, title="Slow EMA")
rsiPeriod = input.int(14, title="RSI Period")
atrPeriod = input.int(14, title="ATR Period")
riskMultiplier = input.float(1.5, title="Volatility Threshold Multiplier", step=0.1)
rsiOB = input.int(70, title="RSI Overbought")
rsiOS = input.int(30, title="RSI Oversold")
// === Indicators ===
fastEMA = ta.ema(close, lengthFast)
slowEMA = ta.ema(close, lengthSlow)
rsi = ta.rsi(close, rsiPeriod)
atr = ta.atr(atrPeriod)
avgATR = ta.sma(atr, atrPeriod)
// === Conditions ===
longCond = ta.crossover(fastEMA, slowEMA) and rsi < rsiOB and atr > avgATR * riskMultiplier
shortCond = ta.crossunder(fastEMA, slowEMA) and rsi > rsiOS and atr > avgATR * riskMultiplier
// === Risk Management ===
longSL = close * 0.98 // 2% Stop Loss
longTP = close * 1.05 // 5% Take Profit
shortSL = close * 1.02
shortTP = close * 0.95
// === Strategy Entries and Exits ===
if (longCond)
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", from_entry="Long", stop=longSL, limit=longTP)
if (shortCond)
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL, limit=shortTP)
// === Visuals ===
plot(fastEMA, title="Fast EMA", color=color.blue)
plot(slowEMA, title="Slow EMA", color=color.red)
hline(rsiOB, "RSI Overbought", color=color.red)
hline(rsiOS, "RSI Oversold", color=color.green)
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.