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

[amibroker] Trend definition code - forward looking



PureBytes Links

Trading Reference Links

Hello All,

here is some code taken from somewhere on the forum; the code is 
excellent in its definition of trend; but unfortunately i think it 
depends on future info due to the use of Zig-Zag function within most 
of the functions used in the code. is there any way around it? i mean 
anyway to have a similarly well defined function for classic trend 
without the disadvantage of being forward looking. perhaps that is 
not possible? 


_SECTION_BEGIN("_HH_LL_Trendbars");
percent = Param("Percent move", 1, 0.5, 10, 0.5);
marg = Param("Threshold % Margin", 1, 0, 3, 0.1);
lastTrough1 = Trough(C, percent, 1);
lastPeak1   = Peak(C, percent, 1);
barsSinceTrough1 = TroughBars(C, percent, 1);
barsSincePeak1  = PeakBars(C, percent, 1);


Color[0] = colorLightGrey;

for(i = 1; i < BarCount; i++)
{

	 if(barsSinceTrough1[i] > barsSincePeak1[i])  // breakdown
	 {
		 if(C[i] < (1 - marg/100)*lastTrough1[i])
			 color[i] = colorRed;
		 else
			 color[i] = color[i-1];
	 }


	 if(barsSinceTrough1[i] < barsSincePeak1[i])  // breakout
	 {
		 if(C[i] > (1 + marg/100)*lastPeak1[i])
			 color[i] = colorBlue;
		 else
			 color[i] = color[i-1];
	 }

}


Plot(C, Name(), color, styleBar);
_SECTION_END();


if not,  then what is the closest thing to a definition of trend? i 
have experimented with a number of things and am currently using 
Heikin-Ashi as my trend indicatorn; its all right but not great (a 
little better than MA croosovers).

thanks
gariki



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/