[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: TTM trend/heiken ashi



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "Alpha" <alpha@xxx> wrote:
>
> Does anybody know what happened to the TTM trend indicator that was referred to in a 
> previous post and linked to the library?
> 
> thanks
>
I found some other code.
This is a very useful indicator for trend.
Please would a kind soul code for AFL.

Basically using Hiken Ashi bars if the 5th bar of the last 5 bars closes above the 50% line of 
the previous 5 bar average, it stays the same color. If the 5th bar closes below the the 50% 
average it changes color.

Code 

{ ModHA PaintBarStudy  1/20/04

modified Heikin-Ashi technique

compares current bar open to close range
with prior bars...if current is within
prior then color remains the same

Taken from
https://www.tradestation.com/Discussions/Topic.aspx?Topic_ID=22399

}
inputs:	CompBars(6), UpColor(Blue), DnColor(Red), BarWidth(1);

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

if BarNumber = 1 then
begin
	haOpen = open;
	haClose = (O+H+L+C)/4;
end;

if BarNumber > 1 then
begin
	haClose = (O+H+L+C)/4; 
	haOpen = (haOpen [1] + haClose [1])/2 ;

{ ................................................................................ }

	if haClose > haOpen then color = UpColor
	else color = DnColor;
	
	for value1 = 1 to CompBars
	begin
		if haOpen <= MaxList(haOpen[value1],haClose[value1]) and
	 		haOpen >= MinList(haOpen[value1],haClose[value1]) and
			haClose <= MaxList(haOpen[value1],haClose[value1]) and
			haClose >= MinList(haOpen[value1],haClose[value1]) then
				color = color[value1];		
	end;

{ ................................................................................ }


//	plotPB(haOpen,haClose,"heikin-ashi",color);
	plotPB(High,Low,"heikin-ashi",color);
	SetPlotWidth(1,BarWidth);
	SetPlotColor(1,color);

end;
{ ................................................................................ }
		

Here is the code 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;
};
}



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/