
Originally Posted by
daddy630
Can anyone please help me on how to script a program in expert advisor so that trades will not occur when MA (at prior bar) is flat?
Suppose there is a fast MA and slow MA. I would like to have no trades when the direction of slow MA was flat on the previous bar.
Thank you and regards,
Daddy630
Hi daddy630,
Code:
extern bool flatmafilter=false;
extern int maperiod=100;
extern int shift=1;
Code:
if(buy/sell entry conditions...
&& (flatmafilter==false || (flatmafilter && NormalizeDouble(iMA(NULL,0,maperiod,0,MODE_SMA,PRICE_CLOSE,shift),Digits)!=NormalizeDouble(iMA(NULL,0,maperiod,0,MODE_SMA,PRICE_CLOSE,shift+1),Digits)))
)buy/sell=true;