Williams’ VIX Fix Indicator for ThinkorSwim

It was posted somewhere earlier in the forum, here is the script. Note: I made some changes

Code:
#Dilbert_VixFix
# V1.0  - 052816 - Dilbert - 1st code cut
# VixFix is a pretty close approximation to the standard VIX or implied volatility.  It can be used on intraday chart aggregations, and on symbols that do not have options.  When VixFIX spikes high it provides some pretty good buy signals.
input OverSold = .1;  # .1 good for SPY 1 day 1 minute chart
input OverBought = .01;  # .01 good for SPY 1 day 1 minute chart
input LengthVF = 22;
input LengthMA = 20;
input percentilelength = 252;
declare lower;
def C = close;
def L = low;
def VixFix = (Highest (C, LengthVF) - L) / (Highest (C, LengthVF)) * 100;
def agg= getaggregationPeriod();
#VixFix.AssignValueColor(Color.GREEN);
#plot OS = OverSold;
#OS.AssignValueColor(Color.CYAN);
#plot OB = OverBought;
#OB.AssignValueColor(Color.CYAN);
plot baseline = 20;


plot range = round((vixfix/highest(vixfix,percentilelength)) * 100,0);

input high_VF = 80;
input low_VF = 20;

AddLabel(yes, "Volatility: "+ aspercent(range/100), if range> range from 1 bars ago then Color.GREEN else Color.RED);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@APOT7 You're going to need to provide more info. Was there an error? Post a screenshot of your chart.
 
I plan on releasing this sometime next week, but @diazlaz was kind enough to port the first version to ThinkorSwim yesterday so I thought it would be fair to share this now, so there is no delay on the development of this indicator.



I recommend watching this video before using the indicator: http://vimeopro.com/user32804960/tradingview-indicators/video/115973132

thinkScript Code

Code:
# VIX_FIX v3 Major Update
# Based on Larry Williams' Vix Fix
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/pJpXG5JH-CM-Williams-Vix-Fix-V3-Ultimate-Filtered-Alerts/
# Video intro: https://vimeopro.com/user32804960/tradingview-indicators/video/115973132

# Discussion: https://usethinkscript.com/threads/williams%E2%80%99-vix-fix-indicator-for-thinkorswim.145/post-5467

input pd = 22;
input bbl = 20;
input mult = 2.0;
input lb = 50;
input ph = 0.85;
input pl = 1.01;

# Downtrend Criterias
input ltLB = 40;
input mtLB = 14;
input str = 3;

# Williams Vix Fix Formula
def wvf = ((highest(close, pd) - low) / (highest(close, pd))) * 100;
def sDev = mult * stdev(wvf, bbl);
def midLine = SimpleMovingAvg(wvf, bbl);
def lowerBand = midLine - sDev;
def upperBand = midLine + sDev;
def rangeHigh = (highest(wvf, lb)) * ph;

#  Filtered Bar Criteria
def upRange = low > low[1] and close > high[1];
def upRange_Aggr = close > close[1] and close > open[1];
#  Filtered Criteria
def filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and(wvf<upperBand and wvf<rangeHigh));
def filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]);

# Alerts Criteria
def alert1 = wvf >= upperBand or wvf >= rangeHigh;
def alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh);
def alert3 = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered;
def alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr;

AssignPriceColor(if alert4 then color.magenta else if alert3 then color.orange else if ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh)) then color.cyan else if (wvf >= upperBand or wvf >= rangeHigh) then color.lime else color.white);
I was able to see all the colors besides, orange.
 
hi ben, i was able to see all the colors besides the orange.. do i missing something in the script? also in the video he's talking about the VSTOP indicator to manage trades, do you have the VSTOP indicator for TOS? thanks and keep the great job you are doing in the forum.
 
@cherif There are variations of the William VixFix posted on the first page. There is no final version. You would have to try them out and see which one works best for you.

@FOTM_8888 @APOT7 I'm not sure. I tried my best with the code already.
 
@BenTen I tried to create a scan, and chose from the drop downs Plot: (I choose each one) and set to Is True, but the scan is not working - would appreciate it if you can please help so we can scan when the VixFix bar turns yellow - thanks!
 
Th
I plan on releasing this sometime next week, but @diazlaz was kind enough to port the first version to ThinkorSwim yesterday so I thought it would be fair to share this now, so there is no delay on the development of this indicator.



I recommend watching this video before using the indicator: http://vimeopro.com/user32804960/tradingview-indicators/video/115973132

thinkScript Code

Code:
# VIX_FIX v3 Major Update
# Based on Larry Williams' Vix Fix
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/pJpXG5JH-CM-Williams-Vix-Fix-V3-Ultimate-Filtered-Alerts/
# Video intro: https://vimeopro.com/user32804960/tradingview-indicators/video/115973132

# Discussion: https://usethinkscript.com/threads/williams%E2%80%99-vix-fix-indicator-for-thinkorswim.145/post-5467

input pd = 22;
input bbl = 20;
input mult = 2.0;
input lb = 50;
input ph = 0.85;
input pl = 1.01;

# Downtrend Criterias
input ltLB = 40;
input mtLB = 14;
input str = 3;

# Williams Vix Fix Formula
def wvf = ((highest(close, pd) - low) / (highest(close, pd))) * 100;
def sDev = mult * stdev(wvf, bbl);
def midLine = SimpleMovingAvg(wvf, bbl);
def lowerBand = midLine - sDev;
def upperBand = midLine + sDev;
def rangeHigh = (highest(wvf, lb)) * ph;

#  Filtered Bar Criteria
def upRange = low > low[1] and close > high[1];
def upRange_Aggr = close > close[1] and close > open[1];
#  Filtered Criteria
def filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and(wvf<upperBand and wvf<rangeHigh));
def filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]);

# Alerts Criteria
def alert1 = wvf >= upperBand or wvf >= rangeHigh;
def alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh);
def alert3 = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered;
def alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr;

AssignPriceColor(if alert4 then color.magenta else if alert3 then color.orange else if ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh)) then color.cyan else if (wvf >= upperBand or wvf >= rangeHigh) then color.lime else color.white);
This is a gold mine
 
@novadolla thanks a lot, I would appreciate it!
# VIX_FIX v3 Major Update
# Based on Larry Williams' Vix Fix
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/pJpXG5JH-CM-Williams-Vix-Fix-V3-Ultimate-Filtered-Alerts/
# Video intro: https://vimeopro.com/user32804960/tradingview-indicators/video/115973132

# Discussion: https://usethinkscript.com/threads/williams’-vix-fix-indicator-for-thinkorswim.145/post-5467

input pd = 22;
input bbl = 20;
input mult = 2.0;
input lb = 50;
input ph = 0.85;
input pl = 1.01;

# Downtrend Criterias
input ltLB = 40;
input mtLB = 14;
input str = 3;

# Williams Vix Fix Formula
def wvf = ((highest(close, pd) - low) / (highest(close, pd))) * 100;
def sDev = mult * stdev(wvf, bbl);
def midLine = SimpleMovingAvg(wvf, bbl);
def lowerBand = midLine - sDev;
def upperBand = midLine + sDev;
def rangeHigh = (highest(wvf, lb)) * ph;

# Filtered Bar Criteria
def upRange = low > low[1] and close > high[1];
def upRange_Aggr = close > close[1] and close > open[1];
# Filtered Criteria
def filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and(wvf<upperBand and wvf<rangeHigh));
def filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]);

# Alerts Criteria
def alert1 = wvf >= upperBand or wvf >= rangeHigh;
def alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh);
def alert3 = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered;
def alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr;



plot signal1 = alert4;
signal1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal1.SetDefaultColor(Color.magenta);

plot signal2 = alert3;
signal2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal2.SetDefaultColor(Color.blue);

plot signal3 = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh));
signal3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal3.SetDefaultColor(Color.cyan);

plot signal4 = (wvf >= upperBand or wvf >= rangeHigh);
signal4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal4.SetDefaultColor(Color.lime);
 
For Mobius' Version of Vix Fix, can anyone help with this?
I'd like to add at the end of the code a snippet that makes an UP arrow and Ring occur when the WVF crosses from above to below the mean
I tried this but of course it doesnt work - can anyone help? thanks


plot UpSignal = if WVF crosses below mean else Double.NaN;

plot DownSignal = if WVF crosses above mean else Double.NaN;


UpSignal.SetDefaultColor(Color.UPTICK);

UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

DownSignal.SetDefaultColor(Color.DOWNTICK);

DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
For Mobius' Version of Vix Fix, can anyone help with this?
I'd like to add at the end of the code a snippet that makes an UP arrow and Ring occur when the WVF crosses from above to below the mean
I tried this but of course it doesnt work - can anyone help? thanks


plot UpSignal = if WVF crosses below mean else Double.NaN;

plot DownSignal = if WVF crosses above mean else Double.NaN;


UpSignal.SetDefaultColor(Color.UPTICK);

UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

DownSignal.SetDefaultColor(Color.DOWNTICK);

DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
If statements must be in the form of if-then-else. In this particular case the "then" tells the arrow on what part of the candle to plot.
Code:
plot UpSignal = if WVF crosses below mean then low else Double.NaN;

plot DownSignal = if WVF crosses above mean then high else Double.NaN;
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
403 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top