Skip to content

Instantly share code, notes, and snippets.

@juliomatcom
Last active May 7, 2022 18:14
Show Gist options
  • Save juliomatcom/0fa8c479839d3ebeb7e1b4639b2456d5 to your computer and use it in GitHub Desktop.
Save juliomatcom/0fa8c479839d3ebeb7e1b4639b2456d5 to your computer and use it in GitHub Desktop.
Tradingview CM_Williams_Vix_Fix with SMA
// @juliomatcom
study("CM_Williams_Vix_Fix", overlay=false)
pd = input(22, title="LookBack Period Standard Deviation High")
bbl = input(20, title="Bolinger Band Length")
mult = input(2.0 , minval=1, maxval=5, title="Bollinger Band Standard Devaition Up")
lb = input(50 , title="Look Back Period Percentile High")
ph = input(.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?")
showMA = input(true, title="Moving Average")
lengthMA = input(10)
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100
wvfAvg = sma(wvf, lengthMA)
sDev = mult * stdev(wvf, bbl)
midLine = sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (highest(wvf, lb)) * ph
rangeLow = (lowest(wvf, lb)) * pl
col = wvf >= upperBand or wvf >= rangeHigh ? lime : gray
plot(hp and rangeHigh ? rangeHigh : na, title="Range High Percentile", style=line, linewidth=4, color=orange)
plot(hp and rangeLow ? rangeLow : na, title="Range High Percentile", style=line, linewidth=4, color=orange)
plot(wvf, title="Williams Vix Fix", style=histogram, linewidth = 4, color=col)
plot(sd and upperBand ? upperBand : na, title="Upper Band", style=line, linewidth = 3, color=aqua)
plot(showMA ? wvfAvg : na, style=line, linewidth=1, color=yellow, title="WVF MA")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment