OPEN-SOURCE SCRIPT

Nifty 50 Trend Identifier DEEP

//version=5
indicator("Nifty 50 Trend Identifier", overlay=true)

// Inputs
shortMA = ta.sma(close, 7)
longMA = ta.sma(close, 20)
atr = ta.atr(14)
avgVolume = ta.sma(volume, 14)

// Trend Conditions
uptrend = shortMA > longMA and close > longMA and volume > avgVolume
downtrend = shortMA < longMA and close < longMA and volume > avgVolume
sideways = math.abs(shortMA - longMA) / longMA < 0.005

// Plotting
plot(shortMA, color=color.blue, title="Short MA")
plot(longMA, color=color.orange, title="Long MA")
bgcolor(uptrend ? color.new(color.green, 90) : downtrend ? color.new(color.red, 90) : sideways ? color.new(color.gray, 90) : na)

Aviso legal