OPEN-SOURCE SCRIPT
5/20 SMA Trade Signal

//version=5
indicator("5/20 SMA Trade Signal", overlay=true)
// Inputs (editable if you want to tweak later)
fastLen = input.int(5, "Fast SMA (default 5)", minval=1)
slowLen = input.int(20, "Slow SMA (default 20)", minval=1)
// Calculate SMAs
fastSMA = ta.sma(close, fastLen)
slowSMA = ta.sma(close, slowLen)
// Plot SMAs
plot(fastSMA, title="Fast SMA", color=color.orange, linewidth=2)
plot(slowSMA, title="Slow SMA", color=color.blue, linewidth=2)
// Signals (use bar close confirmation to avoid intrabar repaint)
bullCross = ta.crossover(fastSMA, slowSMA) and barstate.isconfirmed // 5 SMA closes ABOVE 20 SMA
bearCross = ta.crossunder(fastSMA, slowSMA) and barstate.isconfirmed // 5 SMA closes BELOW 20 SMA
// Label both as "TRADE SIGNAL"
plotshape(bullCross, title="TRADE SIGNAL (5 > 20)", style=shape.labelup, location=location.belowbar,
text="TRADE SIGNAL", color=color.new(color.green, 0), textcolor=color.white, size=size.tiny)
plotshape(bearCross, title="TRADE SIGNAL (5 < 20)", style=shape.labeldown, location=location.abovebar,
text="TRADE SIGNAL", color=color.new(color.red, 0), textcolor=color.white, size=size.tiny)
// Optional alerts for automation/webhooks
alertcondition(bullCross, title="5 SMA crossed ABOVE 20 SMA",
message="TRADE SIGNAL: 5 SMA crossed ABOVE 20 SMA on {{ticker}} @ {{close}}")
alertcondition(bearCross, title="5 SMA crossed BELOW 20 SMA",
message="TRADE SIGNAL: 5 SMA crossed BELOW 20 SMA on {{ticker}} @ {{close}}")
indicator("5/20 SMA Trade Signal", overlay=true)
// Inputs (editable if you want to tweak later)
fastLen = input.int(5, "Fast SMA (default 5)", minval=1)
slowLen = input.int(20, "Slow SMA (default 20)", minval=1)
// Calculate SMAs
fastSMA = ta.sma(close, fastLen)
slowSMA = ta.sma(close, slowLen)
// Plot SMAs
plot(fastSMA, title="Fast SMA", color=color.orange, linewidth=2)
plot(slowSMA, title="Slow SMA", color=color.blue, linewidth=2)
// Signals (use bar close confirmation to avoid intrabar repaint)
bullCross = ta.crossover(fastSMA, slowSMA) and barstate.isconfirmed // 5 SMA closes ABOVE 20 SMA
bearCross = ta.crossunder(fastSMA, slowSMA) and barstate.isconfirmed // 5 SMA closes BELOW 20 SMA
// Label both as "TRADE SIGNAL"
plotshape(bullCross, title="TRADE SIGNAL (5 > 20)", style=shape.labelup, location=location.belowbar,
text="TRADE SIGNAL", color=color.new(color.green, 0), textcolor=color.white, size=size.tiny)
plotshape(bearCross, title="TRADE SIGNAL (5 < 20)", style=shape.labeldown, location=location.abovebar,
text="TRADE SIGNAL", color=color.new(color.red, 0), textcolor=color.white, size=size.tiny)
// Optional alerts for automation/webhooks
alertcondition(bullCross, title="5 SMA crossed ABOVE 20 SMA",
message="TRADE SIGNAL: 5 SMA crossed ABOVE 20 SMA on {{ticker}} @ {{close}}")
alertcondition(bearCross, title="5 SMA crossed BELOW 20 SMA",
message="TRADE SIGNAL: 5 SMA crossed BELOW 20 SMA on {{ticker}} @ {{close}}")
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.