2017 March: Golden Cross Breakouts by Ken Calhoun

ICE Data Services -

2017 March: Golden Cross Breakouts by Ken Calhoun

File Name: GoldenCrossBkout.efs

Description:
Golden Cross Breakouts by Ken Calhoun

Formula Parameters:
GoldenCrossBkout.efs

Fast MA Length: 50
Slow MA Length: 200
Trailing Stop: 2.02017 Mar: Golden Cross Breakouts by Ken Calhoun

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

Download File:
GoldenCrossBkout.efs




EFS Code: 

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

Provided By:  

eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2017. 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 forthefunctionalityoncemodified. eSignalreservestheright to modify and overwrite this EFS file with each new release.


Description:        

    Golden Cross Breakouts by Ken Calhoun


Version:            1.00  01/10/2017


Formula Parameters:                     Default:

Fast MA Length                          50

Slow MA Length                          200

Trailing Stop                           2.0



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(){

    

    setPriceStudy(true);

    setStudyTitle("Golden Cross Breakouts");

    

    setDefaultBarFgColor(Color.red, 0);

    setDefaultBarFgColor(Color.green, 1);

    

    var x=0;

    fpArray[x] = new FunctionParameter("FastMALen", FunctionParameter.NUMBER);

      with(fpArray[x++]){

        setLowerLimit(1);

        setDefault(50);

        setName("Fast Average");

    }

    fpArray[x] = new FunctionParameter("SlowMALen", FunctionParameter.NUMBER);

      with(fpArray[x++]){

        setLowerLimit(1);

        setDefault(200);

        setName("Slow Average");

    }

    fpArray[x] = new FunctionParameter("TrlStop", FunctionParameter.NUMBER);

      with(fpArray[x++]){

        setLowerLimit(0.01);            

        setDefault(2.0);

        setName("Trailing Stop");

    }

}


var bVersion = null;

var bInit = false;

var xFastMA = null;

var xSlowMA = null;

var xHigh = null;

var xLow = null;

var bIsLong = false;

var vHighestHigh = null;

var vStopPrice = null;


function main(FastMALen, SlowMALen, TrlStop){

    

    if (bVersion == null) bVersion = verify();

    if (bVersion == false) return;


    if(getBarState() == BARSTATE_ALLBARS){

        setCursorLabelName("SMA("+FastMALen+")", 0);

        setCursorLabelName("SMA("+SlowMALen+")", 1);

        bInit = false;

    }


    if (!bInit){

        xFastMA = sma(FastMALen);

        xSlowMA = sma(SlowMALen)

        xHigh = high();

        xLow = low();

        bIsLong = false;

        bInit = true;

    }


    var nLow = xLow.getValue(0);

    var nHigh = xHigh.getValue(0);

    var nFastMA = xFastMA.getValue(0);

    var nFastMA1 = xFastMA.getValue(-1);

    var nSlowMA = xSlowMA.getValue(0);

    var nSlowMA1 = xSlowMA.getValue(-1);


    if(nSlowMA1 == null) return;


    if (bIsLong){

        if (nHigh > vHighestHigh && (nLow - TrlStop) > vStopPrice) {

            vStopPrice = (nLow - TrlStop);

            vHighestHigh = nHigh

        }

        else if (nLow <= vStopPrice){

            bIsLong = false;

            drawTextRelative(0, AboveBar1, "\u00EA", Color.red, null, Text.PRESET|Text.CENTER, "Wingdings", 10, "Exit"+rawtime(0));

            drawText("Suggested Long Exit at "+formatPriceNumber(vStopPrice),BottomRow1,Color.red,Text.LEFT,"Text Exit"+rawtime(0));

        }

    }

    

    if (nFastMA > nSlowMA && nFastMA1 <= nSlowMA1) {

        drawTextRelative(0, BelowBar1, "\u00E9", Color.green, null, Text.PRESET|Text.CENTER, "Wingdings", 10, "Long"+rawtime(0));

        drawText("Suggested Long Entry at "+formatPriceNumber(close(0)),TopRow1,Color.green,Text.LEFT,"Text"+rawtime(0));

        bIsLong = true;

        vStopPrice = (nLow - TrlStop);

        vHighestHigh = nHigh;

    }


    return [nFastMA, nSlowMA];

}


function verify(){

    var b = false;

    if (getBuildNumber() < 779){

        

        drawTextAbsolute(5, 35, "This study requires version 12.1 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;

}