I have created the code below:
_SECTION_BEGIN("HEIKIN ASHI EXPLORE 2");
NNClose = (Open+High+Low+2*Close) / 5;
NNOpen = Open;
NNHigh = NNOpen;
NNLow = Min( Low, Min( NNClose, NNOpen ) );
for (i=1; i<BarCount; i++)
NNClose[i] = (Open[i]+High[i]+Low[i]+Close[i]*2) / 5;
NNopen[i] = (NNOpen[i-1] + NNClose[i-1]) / 2; // Here is the problem when using Arrays: Haopen always uses its own previous value
NNHigh[i] = MA(NNOpen[i],5);
NNLow[i] = MA(NNClose[i],5);
barcolor = IIf(NNClose >= NNOpen,colorGreen,colorRed);
PlotOHLC( NNOpen, NNHigh, NNLow, NNClose, "", barcolor, styleCandle );
I get an error message for NNHigh and NNLow.
How can I solve this problem to calculate this NNHigh and NNLow?
@AsaLeffe I already gave you a link to the correct method for coding Heikin-Ashi.
Your code is incorrect and you keep refusing to acknowledge, or use (or thank me for) the correct code.
I looked at the free intro to your favorite book and the tiny modification of the original Heikin Ashi results in a difference of less than 0.01% over hundreds of securities and thousands of bars per security. For example this summary run on 100 stocks over 2,500 bars showing the average original HaClose, modified, and the average difference.
Really why bother? I guess the author had to sell some books.
Use the original and you'll be fine. Or take the original and make the one tiny modification (double weighting the Close) and you will still be fine.
Thank You for Your suggestions. Finally it my code works!