Traders Laboratory - View Single Post - Heikin Ashi Trend Indicator
View Single Post
  #13 (permalink)  
Old 02-06-2007, 08:58 PM
Kiwi's Avatar
Kiwi Kiwi is online now
Kiwi is a bandit in the stochastic darkness

Trader Specs
 
Join Date: Oct 2006
Location: Gold Coast, Oz
Posts: 227
Thanks: 31
Thanked 35 Times in 26 Posts
Re: Heikin Ashi Trend Indicator

Here it is in C++

BaseDataIn 0 is open, 1 is high, 2 is low and 3 is close:

int pos, updn=0;
float jO=0, jH, jL, jC=0, jHm1, jLm1;
sg.DataStartIndex=15;

jL=sg.BaseDataIn[4][0]; jO=jL; jC=jL; jH=jL;
for (pos=5; pos < sg.ArraySize; pos++)
{
jHm1=jH;
jLm1=jL;
jO=(jO+jC)/2;
jC=(sg.BaseDataIn[0][pos]+sg.BaseDataIn[1][pos]+sg.BaseDataIn[2][pos]+sg.BaseDataIn[3][pos])/4;

if(jO>sg.BaseDataIn[1][pos] && jO>jC) jH=jO; else if(jC>sg.BaseDataIn[1][pos]) jH=jC; else jH=sg.BaseDataIn[1][pos];
if(jO<sg.BaseDataIn[2][pos] && jO<jC) jL=jO; else if(jC<sg.BaseDataIn[2][pos]) jL=jC; else jL=sg.BaseDataIn[2][pos];

if(jH>jHm1 && jL>=jLm1) {updn=1;} else
if(jL<jLm1 && jH<=jHm1) {updn=-1;};

if((sg.Input[2].FloatValue!=1 && sg.Input[2].FloatValue!=-1) || (sg.Input[2].FloatValue==1 && updn==1) || (sg.Input[2].FloatValue==-1 && updn==-1))
{
sg.Subgraph[0].Data[pos]=jO;
sg.Subgraph[1].Data[pos]=jH;
sg.Subgraph[2].Data[pos]=jL;
sg.Subgraph[3].Data[pos]=jC;
};
}

Reply With Quote