Announcement

Collapse
No announcement yet.

Heikin Ashi EFS question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Heikin Ashi EFS question

    1) How do you make candle for this EFS larger?. Changed every number in the EFS to see and no go and hit thicker lines in E Signal and nothing. The candles that come with this EFS are just too small.

    2) It looks like the candle color is being drawn 1 bar too late. I put setPlotType(PLOTTYPE_INSTANTCOLORLINE); to get it to back up but it did not work. Normally I place this in every one of my EFS files and it does work. Does something need to be changed. If the color changed one bar earlier that would work give a better entry.


    Thanks
    Earl Zausmer
    [email protected]

    /************************************************** ***************
    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.black, 0);
    setDefaultBarFgColor(Color.black, 1);
    setDefaultBarFgColor(Color.black, 2);
    setDefaultBarFgColor(Color.black, 3);
    setPlotType(PLOTTYPE_DOT, 0);
    setPlotType(PLOTTYPE_DOT, 1);
    setPlotType(PLOTTYPE_DOT, 2);
    setPlotType(PLOTTYPE_DOT, 3);
    setDefaultBarThickness(0, 0);
    setDefaultBarThickness(0, 1);
    setDefaultBarThickness(0, 2);
    setDefaultBarThickness(0, 3);

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

    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(cBull, cBear) {
    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 > 200) iCntr = 0;
    }

    if (haClose1 == null || haOpen1 == null) return;

    haOpen = (haOpen1 + haClose1) / 2;
    haClose = (open() + high() + low() + close()) / 4;
    var haHigh = Math.max(high(), haOpen, haClose);
    var haLow = Math.min(low(), haOpen, haClose);

    //candlesticks
    var vColor = Color.black;
    if (haClose > haOpen) vColor = cBull;
    if (haClose < haOpen) vColor = cBear;
    setBarFgColor(vColor, 2);
    setBarFgColor(vColor, 3);
    drawLineRelative(0, haHigh, 0, haLow, PS_SOLID, 1, Color.black, "Shadow"+iCntr);
    drawLineRelative(0, haOpen, 0, haClose, PS_SOLID, 3, vColor, "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;
    } // End of Heikin-Ashi code

  • #2
    Hello Earl,

    1. The thickness of the candles is controlled by the drawLineRelative() functions. Change the thickness parameter, 3, in the following line. The lines were kept fairly thin because thicker lines drawn with this function show the rounded ends of the line more, which was undesirable for this study.

    drawLineRelative(0, haOpen, 0, haClose, PS_SOLID, 3, vColor, "Body"+iCntr);

    2. I'm not sure what you're trying to accomplish with the coloring here. The color of the candle is based on the close relative to the open for the candle. If the close of the heikin-ashi bar is above it's open the color will be green. Red if below, similar to regular candles.
    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

    Comment

    Working...
    X