Nifty 50 Index

AATMANIRBHAR INDICATOR

150
//version=5
strategy("Aatmanirbhar Indicator with Buy/Sell Orders and Alerts", overlay=true)

// Input parameters
fast_length = input.int(9, "Fast MA Length")
slow_length = input.int(21, "Slow MA Length")

// Calculate moving averages
fast_ma = ta.sma(close, fast_length)
slow_ma = ta.sma(close, slow_length)

// Determine buy and sell signals
buy_signal = ta.crossover(fast_ma, slow_ma)
sell_signal = ta.crossunder(fast_ma, slow_ma)

// Place buy and sell orders
strategy.entry("Buy", strategy.long, when=buy_signal)
strategy.entry("Sell", strategy.short, when=sell_signal)

// Plot buy and sell signals on the chart
plotshape(series=buy_signal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(series=sell_signal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)

// Send alerts for buy and sell signals
alertcondition(condition=buy_signal, title="Buy Signal", message="Buy Signal Detected")
alertcondition(condition=sell_signal, title="Sell Signal", message="Sell Signal Detected")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.