2012 Oct: A Seasonal Strategy With Leveraged ETFs by Gerald GardnerTASC_Oct_2012

ICE Data Services -

HalloweenIndicator.efs  
EFSLibrary - Discussion Board  

File Name: HalloweenIndicator.efs

Description:
A Seasonal Strategy With Leveraged ETFs by Gerald Gardner

Formula Parameters:

HalloweenIndicator.efs

  • Buy Color: lime
  • Sell Color: red

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

Download File:
HalloweenIndicator.efs

HalloweenIndicator.efs

EFS Code:
HalloweenIndicator.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 responsible
for the functionality once modified.  eSignal reserves the right 
to modify and overwrite this EFS file with each new release.

Description:        
A Seasonal Strategy With Leveraged ETFs by Gerald Gardner

Version:            1.00  13/08/2012

Formula Parameters:                     Default:
Buy Color                               lime
Sell Color                              red

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

**********************************/

var fpArray = new Array();

function preMain()
{   
    setStudyTitle("HalloweenIndicator");
    setPriceStudy(true);

    var x=0;
    
    fpArray[x] = new FunctionParameter("gBuyColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Buy Color");    
        setDefault(Color.lime);
    } 
    
    fpArray[x] = new FunctionParameter("gSellColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Sell Color");    
        setDefault(Color.red);
    } 
}


var bInit = false;
var bVersion = null;

var xClose = null;
var xSMA = null;
var xMonth = null;

function main(gBuyColor,gSellColor)
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return; 
    
    if(!bInit)
    {
        xClose = close();        
        xSMA = sma(50);   
        xMonth = getMonth();     
        
        bInit = true;
    }
    
    var vClose = xClose.getValue(0);
    var vSMA   = xSMA.getValue(0);
    var vMonth = xMonth.getValue(0);
    
    if ((vClose == null) || (vSMA == null) || (vMonth == null)) 
        return;
    
    // Back Testing formulas are not for real time analysis.
    // Therefore, prevent processing and exit at bar 0.
    if (getCurrentBarIndex() != 0) 
    {
        var bLStrategy = Strategy.isLong();    

        if (vMonth==10)
        {
            if ((vClose > vSMA) && (!bLStrategy))
            {
               Strategy.doLong("Enter Long", Strategy.MARKET, Strategy.NEXTBAR);        
               drawTextRelative(1, BelowBar1, "Long", Color.black, gBuyColor, Text.PRESET, null, null);           
            }            
        }
        
        if ((vMonth==5) && (bLStrategy))
        {
            Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR);  
            drawTextRelative(1, AboveBar1, "Exit Long", Color.black, gSellColor, Text.PRESET, null, null);         
        }               
    }
        
    return vSMA;
}

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;
}