here is how you do this, 

regards, Ed


SetBarsRequired(sbrAll,sbrAll);

emaPeriod = 20;
lookBackPeriod = 30;
xover = Cross(C,EMA(C,emaPeriod)); // cross over
numxover = Sum(xover,LookBackPeriod); // number of crossovers in lookBackPeriod

Buy = xover AND numxover <= 1; BuyPrice = C;

SetChartOptions(0, chartShowDates);
Plot( C, "\nCandle",colorWhite, styleCandle );
Plot(EMA(C,emaPeriod),"\nEMA(C,emaPeriod)",colorYellow,1);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorWhite,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);




From: jab901 
Sent: Tuesday, August 24, 2010 9:51 PM
To: amibroker@yahoogroups.com 
Subject: [amibroker] If more than 1 ema crossover has occurred in the last 30 
days ignore.


  
How can I program my system to only take signals when there has been 1 ema 
crossover or less in the last 30 days?

This is similar to the turtle traders logic whereby they only took signals if 
the last signal to be generated would have resulted in a profit...

This is in order to try and avoid whipsaws.

Please can anyone help?
Thanks



Reply via email to