2008 June: Profit With ETFs

ICE Data Services -

RSI_TimingModel.efs  EFSLibrary - Discussion Board

File Name: RSI_TimingModel.efs

The following study is based on the June 2008 article, Profit With ETFs, by Gerald Gardner and Trent Gardner.

Formula Parameters:

The study is a long only strategy configured for back testing with the Strategy Analyzer. The strategy colors the price bar corresponding to the entry and exit trades. The price bar will be colored green on entry, red for the time out exit, red for the 2-bar high plus 7.5% exit and yellow for the 2-bar high exit. The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.

Download File:

EFS Code:

/*********************************Provided By:      eSignal (Copyright ) eSignal), a division of Interactive Data     Corporation. 2007. 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 responsible    for the functionality once modified.  eSignal reserves the right     to modify and overwrite this EFS file with each new release.    Description:        Profit With ETFs                    by Gerald Gardner and Trent GardnerVersion:            1.0  4/15/2008Notes:* June 2008 Issue of Stocks and Commodities Magazine* Study requires version 8.0 or later.* Study is configured for back testing only.**********************************/function preMain(){    setStudyTitle("RSI Timing Model");    setPriceStudy(true);    setColorPriceBars(true);    setDefaultPriceBarColor(Color.grey);    setCursorLabelName("Entry",0);    setCursorLabelName("Target",1);    setCursorLabelName("H2",2);    setPlotType(PLOTTYPE_FLATLINES,0);    setPlotType(PLOTTYPE_FLATLINES,1);    setPlotType(PLOTTYPE_FLATLINES,2);    setDefaultBarFgColor(Color.blue,0);    setDefaultBarFgColor(Color.red,1);    setDefaultBarFgColor(Color.red,2);    setDefaultBarThickness(2,0);    setDefaultBarThickness(2,1);    setDefaultBarThickness(2,2);    }var bInit = false;var xRSI  = null;var xSMA  = null;var BarCounter  = 0;var bVersion    = null;var Entry = null;var Target = null;var H2 = null;function main(){    if (bVersion == null) bVersion = verify();    if (bVersion == false) return;        if(bInit == false){        xRSI  = rsi(2,high());        xSMA  = sma(200);        bInit = true;    }            if(xSMA.getValue(0) == null || xRSI.getValue(-1) == null || getCurrentBarIndex() == 0) return;        if(getBarState() == BARSTATE_NEWBAR){        if(Strategy.isLong()){            BarCounter++;        }else{            BarCounter = 0;        }    }                    if (Strategy.isLong() == false) {        Entry = null;        Target = null;        H2 = null;    }        if(Strategy.isLong()){        Target = (high(-2)*1.075);        H2     = high(-2);        if(BarCounter == 6){            Strategy.doSell("TimeOut Exit", Strategy.MARKET, Strategy.THISBAR);            setPriceBarColor(Color.red);        }        else if(high(0) > (high(-2)*1.075) && low(0) < (high(-2)*1.075)){            Strategy.doSell("Limit Exit", Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, (high(-2)*1.075));            setPriceBarColor(Color.cyan);        }        else if(close(0) > high(-2)){            Strategy.doSell("H2 Exit", Strategy.CLOSE, Strategy.THISBAR);            setPriceBarColor(Color.yellow);        }            }        if(!Strategy.isLong()){        if(xRSI.getValue(0) < 2 && xRSI.getValue(-1) > 1 && close(0) > xSMA.getValue(0)){            if(low(0) < (low(-1)*1.025) && high(0) > (low(-1)*1.025)){                Entry = (low(-1)*1.025);                Strategy.doLong("Enter Long", Strategy.LIMIT, Strategy.THISBAR, Strategy.DEFAULT, (low(-1)*1.025));                setPriceBarColor(Color.lime);                BarCounter = 1;            }        }    }            return new Array (Entry, Target, H2);}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;}