Pine Script (TradingView)
This is a TradingView Pine Script example for this indicator. Paste it into the TradingView Pine Editor, add it to your chart, and adjust inputs for your market and timeframe.
//@version=6
indicator("Simple Moving Average (SMA)", overlay=true)
sma20 = ta.sma(close, 20)
sma50 = ta.sma(close, 50)
sma200 = ta.sma(close, 200)
bullish = ta.crossover(sma20, sma50)
bearish = ta.crossunder(sma20, sma50)
plotshape(bullish, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(bearish, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
plot(sma20, "SMA 20", color=color.aqua)
plot(sma50, "SMA 50", color=color.orange)
plot(sma200, "SMA 200", color=color.red, linewidth=2)