how to code to skip 1st trade signal on EA

 

Hi experts,

 

I am new to coding with MT4, hope to get your assistance.

 

I am trying out some EAs and realised that the results might be better if I were to skip my 1st trade signal.

 

Working on a moving average cross strategy with time on UK hour (2pm) start and end 2 hours later (4pm).

Problem here is when I activate the EA for backtesting, the EA will trigger a buy or sell at exactly 2pm when the cross/signal was many bars ago. This resulted in inaccuracy of the strategy.

Hence I am thinking, I there is a way to code to skip the 1st signal then I might be able to get the result I wanted.

 

Hope to receive help from the community.

Thank you. 

 

This should only trigger on a specific bar.

double currFastMA=iMA(FastMAPeriod,...,0);
double prevFastMA=iMA(FastMAPeriod,...,1);
double currSlowMA=iMA(SlowMAPeriod,...,0);
double prevSlowMA=iMA(SlowMAPeriod,...,1);

if(currFastMA>currSlowMA && prevFastMA<prevSlowMA)
   openbuy();
 
pipPod:

This should only trigger on a specific bar.

Thank you so much pipPod !

Will try it out.