OPEN-SOURCE SCRIPT
Strategia 9-30 Candle con Dashboard

//version=5
indicator("Strategia 9-30 Candle con Dashboard", overlay=true)
// Impostazioni EMA
ema9 = ta.ema(close, 9)
ema30 = ta.ema(close, 30)
plot(ema9, color=color.blue, title="EMA 9")
plot(ema30, color=color.red, title="EMA 30")
// RSI e filtro
rsi = ta.rsi(close, 14)
rsiFiltroLong = rsi > 50
rsiFiltroShort = rsi < 50
// Volume e filtro
volFiltroLong = volume > ta.sma(volume, 20)
volFiltroShort = volume > ta.sma(volume, 20)
// Condizioni LONG
longCondition = ta.crossover(ema9, ema30) and close > ema9 and close > ema30 and rsiFiltroLong and volFiltroLong
plotshape(longCondition, title="Entrata Long", location=location.belowbar, color=color.green, style=shape.labelup, text="LONG")
exitLong = ta.crossunder(ema9, ema30)
plotshape(exitLong, title="Uscita Long", location=location.abovebar, color=color.orange, style=shape.labeldown, text="EXIT")
// Condizioni SHORT
shortCondition = ta.crossunder(ema9, ema30) and close < ema9 and close < ema30 and rsiFiltroShort and volFiltroShort
plotshape(shortCondition, title="Entrata Short", location=location.abovebar, color=color.red, style=shape.labeldown, text="SHORT")
exitShort = ta.crossover(ema9, ema30)
plotshape(exitShort, title="Uscita Short", location=location.belowbar, color=color.orange, style=shape.labelup, text="EXIT")
// Background per segnali forti
bgcolor(longCondition ? color.new(color.green, 85) : na, title="BG Long")
bgcolor(shortCondition ? color.new(color.red, 85) : na, title="BG Short")
// Trailing Stop
var float trailPriceLong = na
var float trailPriceShort = na
trailPerc = input.float(0.5, title="Trailing Stop %", minval=0.1, step=0.1)
if (longCondition)
trailPriceLong := close * (1 - trailPerc / 100)
else if (close > trailPriceLong and not na(trailPriceLong))
trailPriceLong := math.max(trailPriceLong, close * (1 - trailPerc / 100))
if (shortCondition)
trailPriceShort := close * (1 + trailPerc / 100)
else if (close < trailPriceShort and not na(trailPriceShort))
trailPriceShort := math.min(trailPriceShort, close * (1 + trailPerc / 100))
plot(trailPriceLong, title="Trailing Stop Long", color=color.green, style=plot.style_linebr, linewidth=1)
plot(trailPriceShort, title="Trailing Stop Short", color=color.red, style=plot.style_linebr, linewidth=1)
// Dashboard
var table dashboard = table.new(position.top_right, 2, 4, border_width=1)
bgCol = color.new(color.gray, 90)
signal = longCondition ? "LONG" : shortCondition ? "SHORT" : "-"
signalColor = longCondition ? color.green : shortCondition ? color.red : color.gray
if bar_index % 1 == 0
table.cell(dashboard, 0, 0, "Segnale:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 0, signal, text_color=color.white, bgcolor=signalColor)
table.cell(dashboard, 0, 1, "RSI:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 1, str.tostring(rsi, format.mintick), text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 0, 2, "Volume:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 2, str.tostring(volume, format.volume), text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 0, 3, "EMA9 > EMA30:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 3, str.tostring(ema9 > ema30), text_color=color.white, bgcolor=bgCol)
// Alert
alertcondition(longCondition, title="Segnale Long", message="LONG: EMA9 incrocia EMA30, RSI > 50, volume alto")
alertcondition(shortCondition, title="Segnale Short", message="SHORT: EMA9 incrocia EMA30 verso il basso, RSI < 50, volume alto")
alertcondition(exitLong, title="Uscita Long", message="Uscita da LONG: EMA9 incrocia EMA30 verso il basso")
alertcondition(exitShort, title="Uscita Short", message="Uscita da SHORT: EMA9 incrocia EMA30 verso l'alto")
indicator("Strategia 9-30 Candle con Dashboard", overlay=true)
// Impostazioni EMA
ema9 = ta.ema(close, 9)
ema30 = ta.ema(close, 30)
plot(ema9, color=color.blue, title="EMA 9")
plot(ema30, color=color.red, title="EMA 30")
// RSI e filtro
rsi = ta.rsi(close, 14)
rsiFiltroLong = rsi > 50
rsiFiltroShort = rsi < 50
// Volume e filtro
volFiltroLong = volume > ta.sma(volume, 20)
volFiltroShort = volume > ta.sma(volume, 20)
// Condizioni LONG
longCondition = ta.crossover(ema9, ema30) and close > ema9 and close > ema30 and rsiFiltroLong and volFiltroLong
plotshape(longCondition, title="Entrata Long", location=location.belowbar, color=color.green, style=shape.labelup, text="LONG")
exitLong = ta.crossunder(ema9, ema30)
plotshape(exitLong, title="Uscita Long", location=location.abovebar, color=color.orange, style=shape.labeldown, text="EXIT")
// Condizioni SHORT
shortCondition = ta.crossunder(ema9, ema30) and close < ema9 and close < ema30 and rsiFiltroShort and volFiltroShort
plotshape(shortCondition, title="Entrata Short", location=location.abovebar, color=color.red, style=shape.labeldown, text="SHORT")
exitShort = ta.crossover(ema9, ema30)
plotshape(exitShort, title="Uscita Short", location=location.belowbar, color=color.orange, style=shape.labelup, text="EXIT")
// Background per segnali forti
bgcolor(longCondition ? color.new(color.green, 85) : na, title="BG Long")
bgcolor(shortCondition ? color.new(color.red, 85) : na, title="BG Short")
// Trailing Stop
var float trailPriceLong = na
var float trailPriceShort = na
trailPerc = input.float(0.5, title="Trailing Stop %", minval=0.1, step=0.1)
if (longCondition)
trailPriceLong := close * (1 - trailPerc / 100)
else if (close > trailPriceLong and not na(trailPriceLong))
trailPriceLong := math.max(trailPriceLong, close * (1 - trailPerc / 100))
if (shortCondition)
trailPriceShort := close * (1 + trailPerc / 100)
else if (close < trailPriceShort and not na(trailPriceShort))
trailPriceShort := math.min(trailPriceShort, close * (1 + trailPerc / 100))
plot(trailPriceLong, title="Trailing Stop Long", color=color.green, style=plot.style_linebr, linewidth=1)
plot(trailPriceShort, title="Trailing Stop Short", color=color.red, style=plot.style_linebr, linewidth=1)
// Dashboard
var table dashboard = table.new(position.top_right, 2, 4, border_width=1)
bgCol = color.new(color.gray, 90)
signal = longCondition ? "LONG" : shortCondition ? "SHORT" : "-"
signalColor = longCondition ? color.green : shortCondition ? color.red : color.gray
if bar_index % 1 == 0
table.cell(dashboard, 0, 0, "Segnale:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 0, signal, text_color=color.white, bgcolor=signalColor)
table.cell(dashboard, 0, 1, "RSI:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 1, str.tostring(rsi, format.mintick), text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 0, 2, "Volume:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 2, str.tostring(volume, format.volume), text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 0, 3, "EMA9 > EMA30:", text_color=color.white, bgcolor=bgCol)
table.cell(dashboard, 1, 3, str.tostring(ema9 > ema30), text_color=color.white, bgcolor=bgCol)
// Alert
alertcondition(longCondition, title="Segnale Long", message="LONG: EMA9 incrocia EMA30, RSI > 50, volume alto")
alertcondition(shortCondition, title="Segnale Short", message="SHORT: EMA9 incrocia EMA30 verso il basso, RSI < 50, volume alto")
alertcondition(exitLong, title="Uscita Long", message="Uscita da LONG: EMA9 incrocia EMA30 verso il basso")
alertcondition(exitShort, title="Uscita Short", message="Uscita da SHORT: EMA9 incrocia EMA30 verso l'alto")
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.