Re: [amibroker] If more than 1 ema crossover has occurred in the last 30 days ignore.

2010-08-25 Thread Edward Pottasch
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





Re: [amibroker] If more than 1 ema crossover has occurred in the last 30 days ignore.

2010-08-25 Thread reinsley

 Le 24/08/2010 21:51, jab901 a écrit :

when there has been 1 ema crossover or less in the last 30 days?


Hi,

or more maybe?

Anyway, the last 30 bars are always modified...

look at the few lines.

Best regards

|// ema xover count
EMAper = Param(EMAper ,20,1,100,1);
myema = EMA(*C*, EMAper );
EMAcrossunder= Cross(myema, *C*);
EMAcrossover = Cross(*C*, myema);

// how many EMA crossoverup and crossoverdown in the last 30 bars
EMAcountup = Sum(EMAcrossover ,30);
EMAcountdn = Sum(EMAcrossunder ,30);

Plot(EMAcrossover, xcrossup,*colorGreen*, *styleHistogram* + 
*styleOwnScale*);
Plot(EMAcrossunder , xcrossdn,*colorRed*, *styleHistogram* + 
*styleOwnScale*);

Plot(EMAcountup , EMAcountup , *colorWhite*,*styleLine*);
Plot(EMAcountdn , EMAcountdn , *colorBlack*,*styleLine*);|