Joe,
That code
is TJ’s kludge to get around the need to initialize HaOpen:
HaOpen = (
Ref(HaOpen,-1) + Ref(HaClose,-1) )/2;
The correct value requires a loop:
HaOpen[0]=
O[0]; HaClose[0]= C[0];
for(i=1;i<BarCount;i++)
{
HaOpen[i]
= (HaOpen[i-1]+HaClose[i-1])/2;
HaClose[i]
= (O[i]+C[i]+H[i]+L[i])/4;
HaHigh[i]
= Max(H[i],Max(HaOpen[i],HaClose[i]));
HaLow[i] =
Min(L[i],Min(HaOpen[i],HaClose[i]));
but inserting the correct line in your code as
I’ve done below will give a near-perfect result.
Regards,
Bob
-----Original
Message-----
From: amibroker@xxxxxxxxxxxxxxx
[mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf
Of Joe Landry
Sent: Sunday, July 15, 2007 6:24
PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Heiken
Ashi indicator
Jack, I'll
ship this to you but from here on out you must promise to look in the program
library. (:>
HTH
Joe L.
////////////////////////////////////
//
// Heikin_Ashi For Amibroker
//
////////////////////////////////////
SetChartBkColor(ParamColor("Outer
panel color ",colorLightGrey)); // color of outer border
SetChartBkGradientFill(
ParamColor("Inner panel color upper half",
colorGrey40),ParamColor("Inner panel color lower half",
colorGrey40));
// color of inner panel
HaClose
=EMA((O+H+L+C)/4,3);
HaOpen = AMA(
Ref( HaClose, -1 ), 0.5 );
HaOpen = (
Ref(HaOpen,-1) + Ref(HaClose,-1) )/2; // ç========
Corrected value.
HaHigh = Max(
H, Max( HaClose, HaOpen ) );
HaLow = Min(
L, Min( HaClose, HaOpen ) );
PlotOHLC(
HaOpen, HaHigh, HaLow, HaClose, "Modified " + Name(), colorBlack,
styleCandle | styleNoLabel );
Title =
"\n" + "" + Name() + ", " + Interval(2) + ",
" + Date() + "\n";
Also in the
program library.
http://www.amibroker.com/library/detail.php?id=714&hilite=StrFind
----- Original Message
-----
To: amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, July 15, 2007 7:04 PM
Subject: [amibroker] Heiken Ashi indicator
hi,
anyone has
heiken ashi indicator? I found an article talking about its fomula as below:
The heikin-ashi
candlestick technique uses modified open-high-low-close (OHLC) values and
displays them as candlesticks. The modified values are computed using these
definitions:
• haClose = (O+H+L+C)/4
• haOpen = (haOpen (previous bar) + haClose (previous bar))/2
• haHigh = Maximum(H, haOpen, haClose)
• haLow = Minimum(L, haOpen, haClose)
is this the
one everyone uses? if anyone has a working heiken ashi indicator AFL file,
please help uploading it or email to me.
thanks a lot
jack
Get
the free Yahoo! toolbar and rest assured with the added security of spyware
protection.