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.