2012 Dec: Using VIX To Forecast The S&P 500 by Trent Gardner

ICE Data Services -

EFS Library


VIX_TimingSystem.efs  EFSLibrary - Discussion Board
  

File Name: VIX_TimingSystem.efs

Description:
Using VIX To Forecast The S&P 500 by Trent Gardner

Formula Parameters:

VIX_TimingSystem.efs
Long Position Color: lime
Short Position Color: red
SMA Period: 50
Days Limit: 11

Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.

Download File:
VIX_TimingSystem.efs

VIX_TimingSystem.efs



EFS Code:

VIX_TimingSystem.efs
/*********************************Provided By:  eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2012. All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only and may be modified and saved under a new file name.  eSignal is not responsiblefor the functionality once modified.  eSignal reserves the right to modify and overwrite this EFS file with each new release.Description:        Using VIX To Forecast The S&P 500 by Trent GardnerVersion:            1.00  12/10/2012Formula Parameters:                     Default:Long Position Color                     limeShort Position Color                    redSMA Period                              50Days Limit                              11Notes:The related article is copyrighted material. If you are not a subscriberof Stocks & Commodities, please visit www.traders.com.**********************************/var fpArray = new Array();function preMain(){       setStudyTitle("VIX_TimingSystem");    setIntervalsBackfill(true);        setPriceStudy(true);    var x=0;        fpArray[x] = new FunctionParameter("gBuyColor", FunctionParameter.COLOR);    with(fpArray[x++])    {        setName("Long Position Color");            setDefault(Color.lime);    }         fpArray[x] = new FunctionParameter("gSellColor", FunctionParameter.COLOR);    with(fpArray[x++])    {        setName("Short Position Color");            setDefault(Color.red);    }     fpArray[x] = new FunctionParameter("gSMAPeriod", FunctionParameter.NUMBER);    with(fpArray[x++])    {        setName("SMA Period");            setLowerLimit(1);        setDefault(50);    }     fpArray[x] = new FunctionParameter("gDaysLimit", FunctionParameter.NUMBER);    with(fpArray[x++])    {        setName("Days Limit");            setLowerLimit(1);        setDefault(11);    } }var bInit = false;var bVersion = null;var xLow = null;var xSMA = null;var xSMA50 = null;function main(gBuyColor,gSellColor,gSMAPeriod,gDaysLimit){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;         if(!bInit)    {        xLow = low(sym("$VIX"));                xSMA = sma(gSMAPeriod,xLow);                     xSMA50 = sma(gSMAPeriod);                             bInit = true;    }        var vLow   = xLow.getValue(-gDaysLimit);    var vSMA   = xSMA.getValue(-gDaysLimit);       var vSMA50 = xSMA50.getValue(-gDaysLimit);          if ((vLow == null) || (vSMA == null) || (vSMA50 == null))         return;        var cntUp = 0;    var cntDown = 0;        for (i=-gDaysLimit; i<0; i++)    {        if (xLow.getValue(i)>xSMA.getValue(i)) cntUp++;        if (xLow.getValue(i)=gDaysLimit)                {                   Strategy.doLong("Enter Long", Strategy.MARKET, Strategy.THISBAR);                           drawTextRelative(0, BelowBar1, "Long", Color.black, gBuyColor, Text.PRESET, null, null);                                                   }                       }                        else            {                if (cntUp>=gDaysLimit)                {                    Strategy.doShort("Enter Short", Strategy.MARKET, Strategy.THISBAR);                      drawTextRelative(0, AboveBar1, "Short", Color.black, gSellColor, Text.PRESET, null, null);                       }                    }         }       return xSMA50.getValue(0);        }function verify() {    var b = false;    if (getBuildNumber() < 779) {        drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",         Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,        null, 13, "error");        drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",         Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,        null, 13, "upgrade");        return b;    } else {        b = true;    }    return b;}