MQL5 Ontick Delay?

 

Hello, this is my conundrum:

I created an EA in MQL5 which involved checking for a certain amount of profit before closing. The EA is able to close exactly at the specified amount when testing in the demo account, yet when I use the EA in a live account, it seems to be reaching that certain amount of profit, then closing not exactly on such (usually less). I have a hypothesis to why this is happening:

The execution of onTick() is slower than a new incoming tick, therefore the EA is calculating on older rates. 

Aside from optimizing the code itself, is there a way I can interrupt the current EA's older onTick execution in favor for the most recent tick?

 
randomuser1999:

Hello, this is my conundrum:

I created an EA in MQL5 which involved checking for a certain amount of profit before closing. The EA is able to close exactly at the specified amount when testing in the demo account, yet when I use the EA in a live account, it seems to be reaching that certain amount of profit, then closing not exactly on such (usually less). I have a hypothesis to why this is happening:

The execution of onTick() is slower than a new incoming tick, therefore the EA is calculating on older rates. 

Aside from optimizing the code itself, is there a way I can interrupt the current EA's older onTick execution in favor for the most recent tick?

If your EA is using Market orders to close then it will almost certainly be down to the live price having changed by the time the order is executed with your broker.

 
Paul Anscombe:

If your EA is using Market orders to close then it will almost certainly be down to the live price having changed by the time the order is executed with your broker.

I see. Aside from optimizing code to a tea I guess there isn’t another way my strategy can be as fast as the market. 😐