2013 October: An Expert Of A System

ICE Data Services -

 

SVEHaTypCross_Bars.efs, SVEHaTypCross_Indicator.efs, SVEHaTypCross_Strategy.efs  

EFSLibrary - Discussion Board  

 

File Name: SVEHaTypCross_Bars.efs, SVEHaTypCross_Indicator.efs, SVEHaTypCross_Strategy.efs

 

Description:
An Expert Of A System

 

Formula Parameters:

SVEHaTypCross_Bars.efs

  • Heikin-Ashi average: 8
  • Typical Price Average: 5
  • Down fill color: grey
  • Up fill color: lime
  • Outline Down color: grey
  • Outline Up color: lime


SVEHaTypCross_Indicator.efs

  • Heikin-Ashi average: 8
  • Typical Price Average: 5


SVEHaTypCross_Strategy.efs

  • Heikin-Ashi average: 8
  • Typical Price Average: 5
  • Long Position Color: cyan
  • Short Position Color: magenta

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

 

Download File:
SVEHaTypCross_Bars.efs
SVEHaTypCross_Indicator.efs
SVEHaTypCross_Strategy.efs

SVEHaTypCross_Bars.efs

SVEHaTypCross_Indicator.efs, SVEHaTypCross_Strategy.efs



EFS Code:

SVEHaTypCross_Bars.efs

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright © 2013) 
    All rights reserved. This sample eSignal Formula Script (EFS)
    is for educational purposes only. Interactive Data Corporation
    reserves the right to modify and overwrite this EFS file with 
    each new release. 

Description:        
    SVEHaTypCross_Bars
    
Version:            1.00  09/08/2013

Formula Parameters:                     Default:
Heikin-Ashi average                     8
Typical Price Average                   5
Down fill color                         grey
Up fill color                           lime
Outline Down color                      grey
Outline Up color                        lime 


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("SVEHaTypCross_Bars");
    setPriceStudy(true);
    setColorPriceBars(true);
                   
    var x = 0;

    fpArray[x] = new FunctionParameter("fpHaCaverage", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Heikin-Ashi average");
        setLowerLimit(1);
        setDefault(8);
    }

    fpArray[x] = new FunctionParameter("fpTypicalAverage", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Typical Price Average");
        setLowerLimit(1); 
        setDefault(5);
    }
    
    fpArray[x] = new FunctionParameter("fpCandleDnFill", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Down fill color");
        setDefault(Color.grey);
    }

    fpArray[x] = new FunctionParameter("fpCandleUpFill", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Up fill color");
        setDefault(Color.lime);
    }

    fpArray[x] = new FunctionParameter("fpOutlineDn", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName( "Outline Down color" );
        setDefault(Color.grey);
    }

    fpArray[x] = new FunctionParameter("fpOutlineUp", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName( "Outline Up color" );
        setDefault(Color.lime);
    }
}

var bInit = false;
var bVersion = null;

var xClose = null;
var xOpen = null;
var xOHLC4 = null;
var xHLC3 = null;
var xHaOpen = null;
var xHaC = null;
var xAVGTyp = null;
var xAVGHaC = null;
var xCross = null;

function main(fpHaCaverage,
              fpTypicalAverage,
              fpCandleDnFill,
              fpCandleUpFill,
              fpOutlineDn,
              fpOutlineUp) 
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;

    if (!bInit)
    {
    	xClose = close();
        xOpen = open();
        xOHLC4 = ohlc4();
        xHLC3 = hlc3();
             
        xHaOpen = efsInternal("Calc_HaOpen", xOHLC4);
        xHaC = efsInternal("Calc_HaC", xOHLC4, xHaOpen);

        xAVGTyp = ema(fpTypicalAverage, xHLC3);
        xAVGHaC = ema(fpHaCaverage, xHaC);
        xCross = efsInternal("Calc_Cross", xAVGTyp, xAVGHaC, xClose, xOpen)
       
        bInit = true; 
    }

    var nClose = 0;
    var nOpen = 0;
    var nCross = 0;

    nClose = xClose.getValue(0);
    nOpen = xOpen.getValue(0);
    nCross = xCross.getValue(0);
 
    if (nCross == 1)
    {
        if (nClose >= nOpen)
            setPriceBarColor(fpCandleUpFill, fpOutlineUp, true, true)
        else
            setPriceBarColor(fpCandleUpFill, fpOutlineUp, true, false);
    }
    if (nCross == 0) 
    {
        if (nClose >= nOpen)
            setPriceBarColor(fpCandleDnFill, fpOutlineDn, true, true)
        else
            setPriceBarColor(fpCandleDnFill, fpOutlineDn, true, false);
    }         
}

function Calc_HaOpen(xSeries)
{
    var nSeries = 0;
    var nHaOpen_Last = 0;
        
    var nReturnValue = 0;   

    nSeries = xSeries.getValue(-1);
             
    if (nSeries == null) 
        return null;
    
    nHaOpen_Last = ref(-1);
    
    nReturnValue = (nSeries + nHaOpen_Last)/2;
    
    return nReturnValue;
}

var xHigh = null;
var xLow = null;

function Calc_HaC(xSeries1, xSeries2)
{
    if (getBarState() == BARSTATE_ALLBARS)
    {
        xHigh = high();
        xLow = low();
    }

    var nSeries1 = 0;
    var nSeries2 = 0;
    var nHigh = 0;
    var nLow = 0;
    
    var nReturnValue = 0;   

    nSeries1 = xSeries1.getValue(0);
    nSeries2 = xSeries2.getValue(0);
    nHigh = xHigh.getValue(0);
    nLow = xLow.getValue(0);

    if (nSeries1 == null || nSeries2 == null)
        return;

    nReturnValue = (nSeries1 + nSeries2 + Math.max(nHigh, nSeries2) + Math.min(nLow, nSeries2)) / 4;   
    
    return nReturnValue;
}

function Calc_Cross(xSeries1, xSeries2, xClose, xOpen)
{
    var nSeries1 = 0;
    var nSeries2 = 0;
    var nClose = 0;
    var nOpen = 0;
    var nCross_Last = 0;
    var nCross = 0;

    var nReturnValue = 0;   

    nClose = xClose.getValue(0);
    nOpen = xOpen.getValue(0);
    nSeries1 = xSeries1.getValue(0);
    nSeries2 = xSeries2.getValue(0);
    
    nCross_Last = ref(-1);
   
    if (nSeries1 == null || nSeries2 == null)
        return;
         
    if (nSeries1 > nSeries2 && nClose > nOpen)
    {    
        nCross = 1
    }
    else
    { 
        if (nSeries1 < nSeries2 && nClose < nOpen)
            nCross = 0;
        else 
            nCross = nCross_Last; 
    }
    
    nReturnValue = nCross;

    return nReturnValue;
}

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

SVEHaTypCross_Indicator.efs

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright © 2013) 
    All rights reserved. This sample eSignal Formula Script (EFS)
    is for educational purposes only. Interactive Data Corporation
    reserves the right to modify and overwrite this EFS file with 
    each new release. 

Description:        
    SVEHaTypCross_Indicator
    
Version:            1.00  09/08/2013

Formula Parameters:                     Default:
Heikin-Ashi average                     8
Typical Price Average                   5

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("SVEHaTypCross_Indicator");
      
    setCursorLabelName("Cross Ind", 0);
    
    var x = 0;

    fpArray[x] = new FunctionParameter("fpHaCaverage", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Heikin-Ashi average");
        setLowerLimit(1);
        setDefault(8);
    }

    fpArray[x] = new FunctionParameter("fpTypicalAverage", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Typical Price Average");
        setLowerLimit(1); 
        setDefault(5);
    }
}

var bInit = false;
var bVersion = null;

var xOHLC4 = null;
var xHLC3 = null;
var xHaOpen = null;
var xHaC = null;
var xAVGTyp = null;
var xAVGHaC = null;
var xCross = null;

function main(fpHaCaverage, fpTypicalAverage) 
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;

    if (!bInit)
    {
    	xOHLC4 = ohlc4();
        xHLC3 = hlc3();
             
        xHaOpen = efsInternal("Calc_HaOpen", xOHLC4);
        xHaC = efsInternal("Calc_HaC", xOHLC4, xHaOpen);

        xAVGTyp = ema(fpTypicalAverage, xHLC3);
        xAVGHaC = ema(fpHaCaverage, xHaC);
        xCross = efsInternal("Calc_Cross", xAVGTyp, xAVGHaC)
       
        bInit = true; 
    }

    var nCross = 0;
    nCross = xCross.getValue(0);

    return (nCross); 
}

function Calc_HaOpen(xSeries)
{
    var nSeries = 0;
    var nHaOpen_Last = 0;
    
    var nReturnValue = 0;   

    nSeries = xSeries.getValue(-1);
             
    if (nSeries == null) 
        return null;
    
    nHaOpen_Last = ref(-1);
    
    nReturnValue = (nSeries + nHaOpen_Last)/2;

    return nReturnValue;
}

var xHigh = null;
var xLow = null;

function Calc_HaC(xSeries1, xSeries2)
{
    if (getBarState() == BARSTATE_ALLBARS)
    {
        xHigh = high();
        xLow = low();
    }

    var nSeries1 = 0;
    var nSeries2 = 0;
    var nHigh = 0;
    var nLow = 0;
    
    var nReturnValue = 0;   

    nSeries1 = xSeries1.getValue(0);
    nSeries2 = xSeries2.getValue(0);
    nHigh = xHigh.getValue(0);
    nLow = xLow.getValue(0);

    if (nSeries1 == null || nSeries2 == null)
        return;

    nReturnValue = (nSeries1 + nSeries2 + Math.max(nHigh, nSeries2) + Math.min(nLow, nSeries2)) / 4;   
    
    return nReturnValue;
}

var xClose = null;
var xOpen = null;

function Calc_Cross(xSeries1, xSeries2)
{
    if (getBarState() == BARSTATE_ALLBARS)
    {
        xClose = close();
        xOpen = open();
    }

    var nSeries1 = 0;
    var nSeries2 = 0;
    var nClose = 0;
    var nOpen = 0;
    var nCross_Last = 0;    
    var nCross = 0;
    
    var nReturnValue = 0;   

    nClose = xClose.getValue(0);
    nOpen = xOpen.getValue(0);
    nSeries1 = xSeries1.getValue(0);
    nSeries2 = xSeries2.getValue(0);

    nCross_Last = ref(-1);
   
    if (nSeries1 == null || nSeries2 == null)
        return;
    
    if (nSeries1 > nSeries2 && nClose > nOpen)
    {    
        nCross = 1
    }
    else
    { 
        if (nSeries1 < nSeries2 && nClose < nOpen)
            nCross = 0;
        else 
            nCross = nCross_Last; 
    }
    
    nReturnValue = nCross;

    return nReturnValue;
}

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

SVEHaTypCross_Strategy.efs

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright © 2013) 
    All rights reserved. This sample eSignal Formula Script (EFS)
    is for educational purposes only. Interactive Data Corporation
    reserves the right to modify and overwrite this EFS file with 
    each new release. 

Description:        
    SVEHaTypCross_Strategy
    
Version:            1.00  09/08/2013

Formula Parameters:                     Default:
Heikin-Ashi average                     8
Typical Price Average                   5
Long Position Color                     cyan
Short Position Color                    magenta

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("SVEHaTypCross_Strategy");
    setPriceStudy(true);
        
    var x = 0;

    fpArray[x] = new FunctionParameter("fpHaCaverage", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Heikin-Ashi average");
        setLowerLimit(1);
        setDefault(8);
    }

    fpArray[x] = new FunctionParameter("fpTypicalAverage", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Typical Price Average");
        setLowerLimit(1); 
        setDefault(5);
    }

    fpArray[x] = new FunctionParameter("fpLongColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Long Position Color");    
        setDefault(Color.cyan);
    } 
    
    fpArray[x] = new FunctionParameter("fpShortColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Short Position Color");    
        setDefault(Color.magenta);
    } 

}

var bInit = false;
var bVersion = null;

var xClose = null;
var xSVEHaTypCross_Indicator = null;

function main(fpHaCaverage, fpTypicalAverage, fpLongColor, fpShortColor) 
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
         
    if (!bInit)
    {
    	xClose = close();
        xSVEHaTypCross_Indicator = efsExternal("SVEHaTypCross_Indicator.efs", fpHaCaverage, fpTypicalAverage);
        
        bInit = true; 
    }

    var nSVEHaTypCross_Indicator_Last = 0;
    var nSVEHaTypCross_Indicator_Current =0;

    var bOpnBuyClsSell = false;
    var bOpnSellClsBuy = false;

    var nFillPrice = 0;
    var nLotSize = 0;

    var bFStrategy = false;
    var bLStrategy = false;
    var bSStrategy = false;

    nSVEHaTypCross_Indicator_Last = xSVEHaTypCross_Indicator.getValue(-1);
    nSVEHaTypCross_Indicator_Current = xSVEHaTypCross_Indicator.getValue(0);

    if (nSVEHaTypCross_Indicator_Last == null || nSVEHaTypCross_Indicator_Current == null)
        return;
    
    if (nSVEHaTypCross_Indicator_Current > 0 && nSVEHaTypCross_Indicator_Last < 1)
        bOpnBuyClsSell = true;
    if (nSVEHaTypCross_Indicator_Current < 1 && nSVEHaTypCross_Indicator_Last > 0)
        bOpnSellClsBuy = true;

    if (getCurrentBarIndex() != 0) 
    {
        bFStrategy = Strategy.isInTrade();
        bLStrategy = Strategy.isLong();
        bSStrategy = Strategy.isShort();

        nFillPrice = xClose.getValue(0);
        nLotSize = Strategy.getDefaultLotSize(); 

        if ((bOpnBuyClsSell) && (!bFStrategy))
        {
            Strategy.doLong("Enter Long", Strategy.CLOSE, Strategy.THISBAR);
            drawTextRelative(0, AboveBar3, "Enter Long", Color.black, fpLongColor, Text.PRESET, null, null, getCurrentBarIndex()+"action");
            drawTextRelative(0, AboveBar2, nLotSize+" @ "+nFillPrice, Color.black, fpLongColor, Text.PRESET, null, null, getCurrentBarIndex()+"price");
            drawShapeRelative(0, AboveBar1, 10, null, Color.blue, Text.PRESET, null); 
        }
        if ((bOpnBuyClsSell) && (bSStrategy))
        {
            Strategy.doLong("Enter Long, Exit Short", Strategy.CLOSE, Strategy.THISBAR);
            drawTextRelative(0, AboveBar3, "Enter Long", Color.black, fpLongColor, Text.PRESET, null, null, getCurrentBarIndex()+"action");
            drawTextRelative(0, AboveBar2, nLotSize+" @ "+nFillPrice, Color.black, fpLongColor, Text.PRESET, null, null, getCurrentBarIndex()+"price");
            drawShapeRelative(0, AboveBar1, 10, null, Color.blue, Text.PRESET, null); 
        }
        if ((bOpnSellClsBuy) && (!bFStrategy))
        {
            Strategy.doShort("Enter Short", Strategy.CLOSE, Strategy.THISBAR);
            drawTextRelative(0, AboveBar3, "Enter Short", Color.black, fpShortColor, Text.PRESET, null, null, getCurrentBarIndex()+"action");
            drawTextRelative(0, AboveBar2, nLotSize+" @ "+nFillPrice, Color.black, fpShortColor, Text.PRESET, null, null, getCurrentBarIndex()+"price"); 
            drawShapeRelative(0, AboveBar1, 10, null, Color.blue, Text.PRESET, null)
        }
        if ((bOpnSellClsBuy) && (bLStrategy))
        {
            Strategy.doShort("Enter Short, Exit Long", Strategy.CLOSE, Strategy.THISBAR);
            drawTextRelative(0, AboveBar3, "Enter Short", Color.black, fpShortColor, Text.PRESET, null, null, getCurrentBarIndex()+"action");
            drawTextRelative(0, AboveBar2, nLotSize+" @ "+nFillPrice, Color.black, fpShortColor, Text.PRESET, null, null, getCurrentBarIndex()+"price"); 
            drawShapeRelative(0, AboveBar1, 10, null, Color.blue, Text.PRESET, null) 
        }
    
    }

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