OPEN-SOURCE SCRIPT
CM_Williams_Vix_Fix Market Top Winit

//version=5
indicator('CM_Williams_Vix_Fix Market Top', overlay=false)
// Inputs
pd = input(22, title='LookBack Period Standard Deviation High')
bbl = input(20, title='Bollinger Band Length')
mult = input.float(2.0, minval=1, maxval=5, title='Bollinger Band Standard Deviation Up')
lb = input(50, title='Look Back Period Percentile High')
ph = input(0.85, title='Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%')
pl = input(1.01, title='Lowest Percentile - 1.10=90%, 1.05=95%, 1.01=99%')
hp = input(false, title='Show High Range - Based on Percentile and LookBack Period?')
sd = input(false, title='Show Standard Deviation Line?')
// Core Calculation (Inverted for Market Top)
wvf_top = (close - ta.lowest(close, pd)) / ta.lowest(close, pd) * 100 // Detect extreme highs
sDev = mult * ta.stdev(wvf_top, bbl)
midLine = ta.sma(wvf_top, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = ta.highest(wvf_top, lb) * ph
rangeLow = ta.lowest(wvf_top, lb) * pl
// Color logic: highlight extreme highs
col = wvf_top >= upperBand or wvf_top >= rangeHigh ? color.red : color.gray
// Plots
plot(wvf_top, title='Williams Vix Fix Market Top', style=plot.style_histogram, linewidth=3, color=col)
// Optional plots
plot(hp ? rangeHigh : na, title='Range High Percentile', style=plot.style_line, linewidth=2, color=color.new(color.orange, 0))
plot(hp ? rangeLow : na, title='Range Low Percentile', style=plot.style_line, linewidth=2, color=color.new(color.orange, 0))
plot(sd ? upperBand : na, title='Upper Band', style=plot.style_line, linewidth=2, color=color.new(color.aqua, 0))
plot(sd ? lowerBand : na, title='Lower Band', style=plot.style_line, linewidth=2, color=color.new(color.aqua, 0))
indicator('CM_Williams_Vix_Fix Market Top', overlay=false)
// Inputs
pd = input(22, title='LookBack Period Standard Deviation High')
bbl = input(20, title='Bollinger Band Length')
mult = input.float(2.0, minval=1, maxval=5, title='Bollinger Band Standard Deviation Up')
lb = input(50, title='Look Back Period Percentile High')
ph = input(0.85, title='Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%')
pl = input(1.01, title='Lowest Percentile - 1.10=90%, 1.05=95%, 1.01=99%')
hp = input(false, title='Show High Range - Based on Percentile and LookBack Period?')
sd = input(false, title='Show Standard Deviation Line?')
// Core Calculation (Inverted for Market Top)
wvf_top = (close - ta.lowest(close, pd)) / ta.lowest(close, pd) * 100 // Detect extreme highs
sDev = mult * ta.stdev(wvf_top, bbl)
midLine = ta.sma(wvf_top, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = ta.highest(wvf_top, lb) * ph
rangeLow = ta.lowest(wvf_top, lb) * pl
// Color logic: highlight extreme highs
col = wvf_top >= upperBand or wvf_top >= rangeHigh ? color.red : color.gray
// Plots
plot(wvf_top, title='Williams Vix Fix Market Top', style=plot.style_histogram, linewidth=3, color=col)
// Optional plots
plot(hp ? rangeHigh : na, title='Range High Percentile', style=plot.style_line, linewidth=2, color=color.new(color.orange, 0))
plot(hp ? rangeLow : na, title='Range Low Percentile', style=plot.style_line, linewidth=2, color=color.new(color.orange, 0))
plot(sd ? upperBand : na, title='Upper Band', style=plot.style_line, linewidth=2, color=color.new(color.aqua, 0))
plot(sd ? lowerBand : na, title='Lower Band', style=plot.style_line, linewidth=2, color=color.new(color.aqua, 0))
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.