Whisker Reversal Oscillator [SpiritualHealer117]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © spiritualhealer117

//@version=5
indicator("whiskers",overlay=false)
len=input(14,"Length")

top_var=array.new<float>(len,0)
bot_var=array.new<float>(len,0)
body_var=array.new<float>(len,0)

for i = 0 to len-1
    top = close[i] > open[i]? close[i]:open[i]
    bottom = open[i] < close[i]? open[i]:close[i]
    top_whisker = high[i]-top
    bottom_whisker = bottom-low[i]
    body = top-bottom
    array.insert(top_var,i,top_whisker)
    array.insert(bot_var,i,bottom_whisker)
    array.insert(body_var,i,body)

avg_top = array.avg(top_var)
avg_bot = array.avg(bot_var)
avg_bod = array.avg(body_var)

botscillator = (avg_bot-avg_bod)/avg_bod
topscillator = (avg_top-avg_bod)/avg_bod

tl=plot(topscillator, color=color.yellow)
bl=plot(botscillator, color=color.blue)
fill(tl, bl, color=topscillator>botscillator?color.new(color.yellow,55):color.new(color.blue,55))
hline(-0.5)
hline(0)
hline(-1)

