OPEN-SOURCE SCRIPT

humbar

//version=5
indicator("20 & 80 Moving Averages", overlay=true)

// Calculate the 20-period Simple Moving Average (SMA)
sma20 = ta.sma(close, 20)

// Calculate the 80-period Simple Moving Average (SMA)
sma80 = ta.sma(close, 80)

// Plot the 20-period SMA
plot(sma20, title="20 SMA", color=color.blue, linewidth=2)

// Plot the 80-period SMA
plot(sma80, title="80 SMA", color=color.red, linewidth=2)

// Optional: Add background color when the 20 SMA crosses above the 80 SMA
bgcolor(sma20 > sma80 ? color.new(color.green, 90) : na, title="Bullish Crossover Background")

// Optional: Add background color when the 20 SMA crosses below the 80 SMA
bgcolor(sma20 < sma80 ? color.new(color.red, 90) : na, title="Bearish Crossover Background")

Pernyataan Penyangkalan