indicator("Dynamic Volatility Indicator [AstroHub]", shorttitle="DVI [AstroHub]", overlay=true) // Input parameters length = input(10, title="Volatility Period") threshold = input(1.5, title="Volatility Threshold") // Calculate price change over the last "length" bars price_change = close - close[length] // Calculate the standard deviation of price change volatility = ta.stdev(price_change, length) // Generate signals for buy and sell buy_signal = price_change > threshold * volatility sell_signal = price_change < -threshold * volatility plotshape(buy_signal, color=color.new(color.blue, 50), style=shape.triangleup, size=size.small, location=location.belowbar, offset=-1, title="Buy Signal") plotshape(sell_signal, color=color.new(color.red, 50), style=shape.triangledown, size=size.small, location=location.abovebar, offset=-1, title="Sell Signal")