back test on MT5 ? - page 2

 
yyk03 #:

Hi everyone,


I have the same issue and I think I've worked out why. (Not 100% sure and hope people who understands more can prove or disprove my theory)

It could be the execution time!

As you might already know, in real/demo trades the total delay time = latency time(Ping) + execution time. We can use VPS to limit the latency time within 1ms, but cannot do anything to improve the execution time, which is mostly 50~200ms to my experiences.(of course it depend on broker/order type/market liquidity... and varies a lot)

However, in MT5's back test, the "delay" in settings only simulates the latency time, and the execution time is... immediate!! It might explain the difference between a real trade and a trade in a back test even with a 100% accuracy.

For example, in a real trade, the latency is 5ms and the execution time is 200ms. It means from the moment you send an order to it's actually filled in the market, it takes 5ms + 200ms = 205ms.

However, in MT5's back test, you can only simulate the latency time 5ms and the execution time is 0. So the result will be from the moment your send an order to it's actually filled in the market, it takes only 5ms.


So why I reached the conclusion above? I did experiences in an EA to send several orders at the same time in the asynchronous way. Right after the orders were sent, I added some codes checked the result and found out that they were all filled. It would be impossible in real trades(must wait for latency time and execution time), but in MT5 all orders seem always to be filled immediately.


Last, what's the solution? I'm using the Sleep() function before any order sending or order modifying codes for back test(of course only for back test, always delete it in real trades). I might not be the best way and if anyone have better ideas please share it with us. Thanks!!

reviving old thread and forgive me if my understanding is lacking- but couldnt you just make the latency 205ms in your backtest example to simulate real world times?