Announcement

Collapse
No announcement yet.

2004 Feb: eSignal_HeikinAshi.efs

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2004 Feb: eSignal_HeikinAshi.efs

    File Name: eSignal_HeikinAshi.efs


    Description:
    Based on Using The Heikin-Ashi Technique by Dan Valcu. This article appeared in the February 2004 issue of Stock & Commodities. The main formula is eSignal_HeikinAshi.efs. There are two other indicators from the article, which are also included below (eSignal_HA_OC.efs and eSignal_HADiffCO.efs).

    Formula Parameters:
    eSignal_HeikinAshi.efs
    Bullish Candles (Color): Green
    Bearish Candles (Color): Red

    eSignal_HA_OC.efs
    HA-Open Color: Red
    HA-Close Color: Blue
    HA-Open Thickness: 2
    HA-Close Thickness: 2
    Enable Alerts: true
    Enable Forex Conversion: false
    Forex Conversion Factor: 100000

    eSignal_HADiffCO.efs
    SMA Periods: 3
    HA-DiffCO Color: Blue
    SMA HA-DiffCO Color: Red
    HA-DiffCO Thickness: 2
    SMA HA-DiffCO Thickness: 2
    Enable Alerts: true
    Enable Forex Conversion: false
    Forex Conversion Factor: 100000

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

    7/28/2004 - eSignal_HA_OC.efs and eSignal_HA_DiffCO.efs Versions 1.1 now include alert arrows for crosses and Edit Studies options for disabling alerts as well as Forex price conversion and the Forex conversion factor.

    Download File:
    eSignal_HeikinAshi.efs
    eSignal_HA_OC.efs Version 1.1 7/28/2004
    eSignal_HA_DiffCO.efs Version 1.1 7/28/2004




    EFS Code:

    eSignal_HeikinAshi.efs
    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    EFS Formula : Heikin-Ashi

    Notes:
    * Non-price study
    * Draws most recent 200 bars
    * Formula Parameters 
        - Bullish Color     Default: Green
        - Bearish Color     Default: Red

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

    function preMain() {
        
    setStudyTitle("Heikin-Ashi Chart ");
        
    setCursorLabelName("HA-High"0);
        
    setCursorLabelName("HA-Low"1);
        
    setCursorLabelName("HA-Open"2);
        
    setCursorLabelName("HA-Close"3);
        
    setDefaultBarFgColor(Color.black0);
        
    setDefaultBarFgColor(Color.black1);
        
    setDefaultBarFgColor(Color.black2);
        
    setDefaultBarFgColor(Color.black3);
        
    setPlotType(PLOTTYPE_DOT0);
        
    setPlotType(PLOTTYPE_DOT1);
        
    setPlotType(PLOTTYPE_DOT2);
        
    setPlotType(PLOTTYPE_DOT3);
        
    setDefaultBarThickness(00);
        
    setDefaultBarThickness(01);
        
    setDefaultBarThickness(02);
        
    setDefaultBarThickness(03);

        var 
    fp1 = new FunctionParameter("cBull"FunctionParameter.COLOR);
        
    fp1.setName("Bullish Candles");
        
    fp1.setDefault(Color.green);

        var 
    fp2 = new FunctionParameter("cBear"FunctionParameter.COLOR);
        
    fp2.setName("Bearish Candles");
        
    fp2.setDefault(Color.red);
        
        
    }

    var 
    haClose null;
    var 
    haOpen null;
    var 
    haClose1 null;
    var 
    haOpen1 null;
    var 
    iCntr 0;

    function 
    main(cBullcBear) {
        var 
    nState getBarState();
        
        if (
    nState == BARSTATE_NEWBAR) {
            if ((
    haClose == null || haOpen == null) && close(-1) != null) {
                
    haClose close(-1);
                
    haOpen open(-1);
            }
            
    haClose1 haClose;
            
    haOpen1 haOpen;
            
    iCntr += 1;
            if (
    iCntr 200iCntr 0;
        }

        if (
    haClose1 == null || haOpen1 == null) return;
        
        
    haOpen = (haOpen1 haClose1) / 2;
        
    haClose = (open() + high() + low() + close()) / 4;
        var 
    haHigh Math.max(high(), haOpenhaClose);
        var 
    haLow Math.min(low(), haOpenhaClose);
        
        
    //candlesticks
        
    var vColor Color.black;
        if (
    haClose haOpenvColor cBull;
        if (
    haClose haOpenvColor cBear;
        
    setBarFgColor(vColor2);
        
    setBarFgColor(vColor3);
        
    drawLineRelative(0haHigh0haLowPS_SOLID1Color.black"Shadow"+iCntr);
        
    drawLineRelative(0haOpen0haClosePS_SOLID3vColor"Body"+iCntr);
        
        var 
    retArray = new Array(4);
        
    retArray[0] = haHigh.toFixed(2)*1;
        
    retArray[1] = haLow.toFixed(2)*1;
        
    retArray[2] = haOpen.toFixed(2)*1;
        
    retArray[3] = haClose.toFixed(2)*1;

        return 
    retArray

    eSignal_HA_OC.efs
    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    EFS Formula : Heikin-Ashi Open Close Indicator

    Version 1.1     7/28/2004

    1.1
    * Added Alert Arrows on MA cross.
    * Added Option to disable Alerts
    * Added Option for Forex Price Conversion and Conversion Factor

    Notes:
    * Non-price study
    * Formula Parameters
        - HA-Open Color             Default: Red
        - HA-Close Color            Default: Blue
        - HA-Open Thickness         Default: 2
        - HA-Close Thickness        Default: 2
        - Enable Alerts             Default: true
        - Enabel Forex Conversion   Default: false
        - Forex Conversion Factor   Default: 100000
    *********************************/

    function preMain() {
        
    setStudyTitle("Heikin-Ashi Open Close Indicator ");
        
    setCursorLabelName("HA-Open"0);
        
    setCursorLabelName("HA-Close"1);
        
    setShowTitleParameters(false);

        var 
    fp1 = new FunctionParameter("cOpen"FunctionParameter.COLOR);
        
    fp1.setName("HA-Open Color");
        
    fp1.setDefault(Color.red);

        var 
    fp2 = new FunctionParameter("cClose"FunctionParameter.COLOR);
        
    fp2.setName("HA-Close Color");
        
    fp2.setDefault(Color.blue);
        
        var 
    fp3 = new FunctionParameter("nOThickness"FunctionParameter.NUMBER);
        
    fp3.setName("HA-Open Thickness");
        
    fp3.setLowerLimit(1);
        
    fp3.setDefault(2);

        var 
    fp4 = new FunctionParameter("nCThickness"FunctionParameter.NUMBER);
        
    fp4.setName("HA-Close Thickness");
        
    fp4.setLowerLimit(1);
        
    fp4.setDefault(2);

        var 
    fp5 = new FunctionParameter("bAlerts"FunctionParameter.BOOLEAN);
        
    fp5.setName("Enable Alerts");
        
    fp5.setDefault(true);

        var 
    fp6 = new FunctionParameter("bForex"FunctionParameter.BOOLEAN);
        
    fp6.setName("Enable Forex Conversion");
        
    fp6.setDefault(false);

        var 
    fp7 = new FunctionParameter("nFactor"FunctionParameter.NUMBER);
        
    fp7.setName("Forex Conversion Factor");
        
    fp7.setLowerLimit(1);
        
    fp7.setDefault(100000);
    }

    var 
    haClose null;
    var 
    haOpen null;
    var 
    haClose1 null;
    var 
    haOpen1 null;
    var 
    bEdit true;
    var 
    cntr 0;

    function 
    main(cOpencClosenOThicknessnCThicknessbAlerts,
                  
    bForexnFactor) {
        var 
    nState getBarState();
        
        if (
    bEdit == true) {
            
    setDefaultBarFgColor(cOpen0);
            
    setDefaultBarFgColor(cClose1);
            
    setDefaultBarThickness(nOThickness0);
            
    setDefaultBarThickness(nCThickness1);
            
    bEdit false;
        }
        
        if (
    nState == BARSTATE_NEWBAR) {
            
    cntr++;
            if ((
    haClose == null || haOpen == null) && close(-1) != null) {
                
    haClose close(-1);
                
    haOpen open(-1);
            }
            
    haClose1 haClose;
            
    haOpen1 haOpen;
        }

        if (
    haClose1 == null || haOpen1 == null) return;
        
        
    haOpen = (haOpen1 haClose1) / 2;
        
    haClose = (open() + high() + low() + close()) / 4;
        
        if (
    bForex == false || bForex == "false"nFactor 1;
        var 
    retArray = new Array(2);
        
    retArray[0] = (haOpen*nFactor).toFixed(2)*1;
        
    retArray[1] = (haClose*nFactor).toFixed(2)*1;

        
    // Alerts
        
    if (haClose1 != null && haOpen1 != null && (bAlerts == true || bAlerts == "true") ) {
            if (
    haClose1 haOpen1 && haClose haOpen) { // Up Arrow
                
    drawShapeRelative(0haClose1*nFactorShape.UPARROWnullColor.lime,
                    
    Shape.TOP|Shape.ONTOP"arrow"+cntr);
            } else if (
    haClose1 haOpen1 && haClose haOpen) {  // Down Arrow
                
    drawShapeRelative(0haClose1*nFactorShape.DOWNARROWnullColor.maroon,
                    
    Shape.BOTTOM|Shape.ONTOP"arrow"+cntr);
            } else {
                
    removeShape("arrow"+cntr);
            }
        }

        return 
    retArray

    eSignal_HADiffCO.efs
    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    EFS Formula : Heikin-Ashi DiffCO Indicator

    Version 1.1     7/28/2004

    1.1
    * Added Alert Arrows on MA cross.
    * Added Option to disable Alerts
    * Added Option for Forex Price Conversion and Conversion Factor

    Notes:
    * Non-price study
    * Formula Parameters
        - SMA Periods               Default: 3
        - HA-DiffCO Color           Default: Blue
        - SMA HA-DiffCO Color       Default: Red
        - HA-DiffCO Thickness       Default: 2
        - SMA HA-DiffCO Thickness   Default: 2
        - Enable Alerts             Default: true
        - Enable Forex Conversion   Default: false
        - Forex Conversion Factor   Default: 100000
    *********************************/

    function preMain() {
        
    setStudyTitle("Heikin-Ashi DiffCO Indicator ");
        
    setCursorLabelName("HA-DiffCO"0);
        
    setCursorLabelName("SMA HA-DiffCO"1);
        
    setShowTitleParameters(false);

        var 
    fp0 = new FunctionParameter("nLength"FunctionParameter.NUMBER);
        
    fp0.setName("SMA Periods");
        
    fp0.setLowerLimit(1);
        
    fp0.setDefault(3);

        var 
    fp1 = new FunctionParameter("cDiffCO"FunctionParameter.COLOR);
        
    fp1.setName("HA-DiffCO Color");
        
    fp1.setDefault(Color.blue);

        var 
    fp2 = new FunctionParameter("cMADiffCO"FunctionParameter.COLOR);
        
    fp2.setName("SMA HA-DiffCO Color");
        
    fp2.setDefault(Color.red);
        
        var 
    fp3 = new FunctionParameter("nDThickness"FunctionParameter.NUMBER);
        
    fp3.setName("HA-DiffCO Thickness");
        
    fp3.setLowerLimit(1);
        
    fp3.setDefault(2);

        var 
    fp4 = new FunctionParameter("nMAThickness"FunctionParameter.NUMBER);
        
    fp4.setName("SMA HA-DiffCO Thickness");
        
    fp4.setLowerLimit(1);
        
    fp4.setDefault(2);

        var 
    fp5 = new FunctionParameter("bAlerts"FunctionParameter.BOOLEAN);
        
    fp5.setName("Enable Alerts");
        
    fp5.setDefault(true);

        var 
    fp6 = new FunctionParameter("bForex"FunctionParameter.BOOLEAN);
        
    fp6.setName("Enable Forex Conversion");
        
    fp6.setDefault(false);

        var 
    fp7 = new FunctionParameter("nFactor"FunctionParameter.NUMBER);
        
    fp7.setName("Forex Conversion Factor");
        
    fp7.setLowerLimit(1);
        
    fp7.setDefault(100000);
    }

    var 
    haClose null;
    var 
    haOpen null;
    var 
    haClose1 null;
    var 
    haOpen1 null;
    var 
    bEdit true;
    var 
    aDiffCO null;
    var 
    haDiffCO null;
    var 
    haDiffCO_1 null;
    var 
    vMA null;
    var 
    vMA_1 null;
    var 
    cntr 0;

    function 
    main(nLengthcDiffCOcMADiffCOnDThicknessnMAThicknessbAlerts,
                  
    bForexnFactor) {
        var 
    nState getBarState();
        var 
    0;
        var 
    dSum 0;
        
        if (
    bEdit == true) {
            
    setDefaultBarFgColor(cDiffCO0);
            
    setDefaultBarFgColor(cMADiffCO1);
            
    setDefaultBarThickness(nDThickness0);
            
    setDefaultBarThickness(nMAThickness1);
            
    aDiffCO = new Array(nLength);
            
    bEdit false;
        }
        
        if (
    nState == BARSTATE_NEWBAR) {
            
    cntr++;
            if ((
    haClose == null || haOpen == null) && close(-1) != null) {
                
    haClose close(-1);
                
    haOpen open(-1);
            }
            
    haClose1 haClose;
            
    haOpen1 haOpen;
            if (
    haDiffCO != null) {
                
    aDiffCO.pop();
                
    aDiffCO.unshift(haDiffCO);
                
    haDiffCO_1 haDiffCO;
            }
            
    vMA_1 vMA;
        }

        if (
    haClose1 == null || haOpen1 == null) return;
        
        
    haOpen = (haOpen1 haClose1) / 2;
        
    haClose = (open() + high() + low() + close()) / 4;
        
        
    haDiffCO = (haClose haOpen);
        
    aDiffCO[0] = haDiffCO;
        
        
    vMA null;
        
        if (
    aDiffCO[nLength-1] != null) {
            for (
    0nLength; ++i) {
                
    dSum += aDiffCO[i];
            }
            
    vMA = (dSum nLength);
        }
        
        if (
    bForex == false || bForex == "false"nFactor 1;
        var 
    retArray = new Array(2);
        
    retArray[0] = (haDiffCO*nFactor).toFixed(2)*1;
        
    retArray[1] = vMA*nFactor;

        
    // Alerts
        
    if (haDiffCO_1 != null && vMA_1 != null && (bAlerts == true || bAlerts == "true") ) {
            if (
    haDiffCO_1 vMA_1 && haDiffCO vMA) { // Up Arrow
                
    drawShapeRelative(0haDiffCO_1*nFactorShape.UPARROWnullColor.lime,
                    
    Shape.TOP|Shape.ONTOP"arrow"+cntr);
            } else if (
    haDiffCO_1 vMA_1 && haDiffCO vMA) {  // Down Arrow
                
    drawShapeRelative(0haDiffCO_1*nFactorShape.DOWNARROWnullColor.maroon,
                    
    Shape.BOTTOM|Shape.ONTOP"arrow"+cntr);
            } else {
                
    removeShape("arrow"+cntr);
            }
        }
        
        return 
    retArray

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X