ATR Oscillator - Index (Average True range Oscillator)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © KaptanKirk - Süleyman Sülün - @TheSulun

//@version=5
indicator(title="Average True Range Oscillator", shorttitle="ATRO", format=format.price, precision=2, timeframe="", timeframe_gaps=true, overlay = false)

ATR_per=input.int(14, "ATR Per")
atr=ta.atr(ATR_per)
Max_Min_per=input.int(20,"Period for ATR Max and Min") // Within how many bars (periods) should the ATR max and min values be determined?
atrMax=ta.highest(atr,Max_Min_per) // Maximum ATR value in the specified period
atrMin=ta.lowest(atr,Max_Min_per) // Minimum ATR value in the specified period
ATR_Oscillator=100/((atrMax-atrMin)/(atr-atrMin)) // Calculation of the percentage of the difference between the Max and Min ATR values in the specified range of the instantaneous ATR value. So the process of converting this range to % oscillator.
ATRO_SMA_Per=input.int(1, minval=1, title="SMA for ATR Oscillator") // The 'SMA Period' of the 'ATR Oscillator' can be increased to soften the 'ATR Oscillator' plot.
plot(ta.sma(ATR_Oscillator,ATRO_SMA_Per), title="ATR Oscillator", color=color.navy, linewidth = 2, style=plot.style_line)
