Heikin Ashi PaintBarStudy [TS CODE]

Discussion in 'TradeStation' started by feijian0000, Sep 17, 2012.

  1. {Heikin Ashi PaintBarStudy (not an indicator)
    Heikin-Ashi technique for visualization of trend -
    Correctly paints bars with no candlesticks if you hide regular bar style as follows:
    Format Symbol, style tab, select Dot on Close, color to white or black }

    inputs:
    UpColor(white),
    DnColor(black);

    vars:
    haClose(0),
    haOpen(0),
    haHigh(0),
    haLow(0),
    color(0);

    if BarNumber = 1 then
    begin
    haOpen = open;
    haClose = (O+H+L+C)/4;
    haHigh = MaxList( high, haOpen, haClose);
    haLow = MinList( low, haOpen,haClose);
    end;

    if BarNumber > 1 then
    begin
    haClose = (O+H+L+C)/4; ////average bar price
    haOpen = (haOpen [1] + haClose [1])/2 ; ////avg open/close 1 bar ago
    haHigh = MaxList(High, haOpen, haClose) ; ////highest of high,open,close
    haLow = MinList(Low, haOpen, haClose) ; //// lowest of low, open, close

    if haClose > haOpen then color = UpColor
    else color = DnColor;

    plotPB(haOpen,haClose,"heikin-ashi",color);
    SetPlotWidth(1,4);
    SetPlotColor(1,color);
    end;