Nifty 50 Index

Testing

59
//version=5
indicator("Range Filter with Support and Resistance", overlay=true)

// Inputs for Range Filter
length = input(10, title="Range Length")
multiplier = input.float(1.5, title="Multiplier")

// Calculate Range Filter
src = close
basis = ta.sma(src, length)
range = ta.stdev(src, length) * multiplier
upper = basis + range
lower = basis - range

// Trend Detection
trendUp = src > upper ? 1 : na
trendDown = src < lower ? -1 : na
trend = ta.valuewhen(trendUp or trendDown, trendUp ? 1 : -1, 0)

// Support and Resistance Levels
lookback = input(20, title="Lookback Period for Support/Resistance")
support = ta.lowest(low, lookback)
resistance = ta.highest(high, lookback)

// Plotting
plot(upper, color=color.new(color.green, 70), linewidth=1, title="Upper Range")
plot(lower, color=color.new(color.red, 70), linewidth=1, title="Lower Range")
hline(support, "Support", color=color.blue, linestyle=hline.style_dotted, linewidth=2)
hline(resistance, "Resistance", color=color.orange, linestyle=hline.style_dotted, linewidth=2)

// Background Color for Trends
bgcolor(trend == 1 ? color.new(color.green, 90) : trend == -1 ? color.new(color.red, 90) : na)

// Alerts for Breakouts
alertcondition(src > resistance, title="Price Above Resistance", message="Price broke above resistance!")
alertcondition(src < support, title="Price Below Support", message="Price broke below support!")

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.