Combo Williams Vix Fix Indicator for ThinkorSwim

diazlaz

Well-known member
2019 Donor
VIP
Here is the initial port of Combo Williams Vix Fix (Twin version) to ToS, as per requested by @Ken_Adams.

g1thMXG.png


E4OCqgh.png


Ruby:
#Combo Williams Vix Fix (Twin version) to ToS
#
#CREDITS
# capissimo
#
#CHANGELOG
# 2020.04.22 1.0 @diazlaz - Initial Port/interpretation 
#
#LINKS
# https://www.tradingview.com/script/tVtxISLu-combo-williams-vix-fix-twin-version/
#
#DESCRIPTION
#This is a very powerful Williams' Vix Fix indicator.
#My implementation of this wonderful indicator features both up and down movements.
#Both up & down flavors have two versions (fields tp and tp2, each having two values).
#

declare lower;

#INPUTS
input tp = 1;     #VixFix UP [1,2]
input tp2 = 1;    #VixFix DN [1,2]
input pd = 22;    #LookBack Period Standard Deviation High/Low
input bbl = 20;   #Bolinger Band Length
input mult = 2.0; #Bollinger Band Standard Deviation Up/Dn
input p = 60;     #LookBack
input lb = 50;    #Look Back Period Percentile High/Low
input ph = 0.85;  #Highest Percentile
input pl = 1.01;  #Lowest Percentile
input hp = yes;   #Show High Range - Based on Percentile and LookBack Period
input sd = no;    #Show Standard Deviation Line
input hp2 = no;   #Show Low Range - Based on Percentile and LookBack Period
input sd2 = no;   #Show Standard Deviation Line

script scaleMinimax {
    input x = close;
    input p = 5;
    input Min = .01;
    input Max =   1;
    def hh = Highest(x, p);
    def ll   = Lowest(x, p);
    plot data = (((Max - Min) * (x - ll)) /  (hh - ll)) + Min;
}

#CORE
def prix  = scaleMinimax(close, p, 0, 1);
def prixn = 1 - prix;
def neg   = 1 - scaleMinimax(high, p, 0, 1);
def hi    = scaleMinimax(high, p, 0, 1);
def lo    = scaleMinimax(low, p, 0, 1);

def up1   = (Highest(prix, pd) - lo) / Highest(prix, pd);
def up2   = (Highest(prix, pd) - hi) / Highest(prix, pd);
def dn1   = (Highest(prixn, pd) - neg) / Highest(prixn, pd);
def dn2   = scaleMinimax((high - Lowest(close, pd)) / Lowest(close, pd), p, 0, 1);
def wvf   = If(tp == 1, up1, up2);
def wvfr  = If(tp2 == 1, dn1, dn2);

def sDev      = mult * StDev(wvf, bbl);
def midLine   = Average(wvf, bbl);
def lowerBand = midLine - sDev;
def upperBand = midLine + sDev;
def rangeHigh = (Highest(wvf, lb)) * ph;
def rangeLow  = (Lowest(wvf, lb)) * pl;
def col = If (wvf >= upperBand or wvf >= rangeHigh, -100, 0);

def sDev2      = mult * StDev(wvfr, bbl);
def midLine2   = Average(wvfr, bbl);
def lowerBand2 = midLine2 - sDev2;
def upperBand2 = midLine2 + sDev2;
def rangeHigh2 = (Highest(wvfr, lb)) * ph;
def rangeLow2  = (Lowest(wvfr, lb)) * pl;
def col2 = If(wvfr >= upperBand2 or wvfr >= rangeHigh2, 100, 0);

#PLOTS
plot pwvfr1 = wvfr;
pwvfr1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
pwvfr1.AssignValueColor(if wvfr >= upperBand2 or wvfr >= rangeHigh2 then Color.GREEN else Color.DARK_GRAY);
pwvfr1.SetLineWeight(4);

plot pwvfr2 = wvfr;
pwvfr2.SetLineWeight(1);
pwvfr2.SetDefaultColor(Color.BLACK);

plot pwvf1 = wvf;
pwvf1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
pwvf1.AssignValueColor(if wvf >= upperBand or wvf >= rangeHigh then Color.RED else Color.DARK_GRAY);
pwvf1.SetLineWeight(4);

plot pwvf2 = wvfr;
pwvf2.SetLineWeight(1);
pwvf2.SetDefaultColor(Color.BLACK);

plot pRPH = if hp and rangeHigh then rangeHigh else Double.NaN; #Range High Percentile
pRPH.AssignValueColor(GetColor(7));

plot pRPL = if hp and rangeLow then rangeLow else Double.NaN; #Range Low Percentile
pRPL.AssignValueColor(GetColor(7));

plot pUpperBand = if sd and upperBand then upperBand else Double.NaN; #Upper Band
pUpperBand.AssignValueColor(GetColor(5));

plot pRPH2 = if hp2 and rangeHigh2 then rangeHigh2 else Double.NaN; #Range High Percentile
pRPH2.AssignValueColor(GetColor(5));

plot pRPL2 = if hp2 and rangeLow2 then rangeLow2 else Double.NaN; #Range Low Percentile
pRPL2.AssignValueColor(GetColor(5));

plot pUpperBand2 = if sd2 and upperBand2 then upperBand2 else Double.NaN; #Upper Band
pUpperBand2.AssignValueColor(GetColor(7));

#END of Combo Williams Vix Fix (Twin version) to ToS

Share your test results and pairings.

Happy Trading.
 

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.
Top