vdemydiuk / mtapi

MetaTrader API (terminal bridge)
MIT License
529 stars 283 forks source link

What does the "BacktestingLockTicks" EA option do? #237

Closed eabase closed 3 years ago

eabase commented 4 years ago

^^ that.

vdemydiuk commented 3 years ago

MtApi has aync mode of sending events (tick, candle) from MQL (terminal) side to clients. For example, MtApi expert (MQL side) received new tick and it does not wait after sending the tick to the clients. So if you are using backtesting the expert receives big count of ticks in short time and sends it to clients side. Client side will perform tick and will try to send command (open order) to terminal but price will be out of date. I have added parameter BacktestingLockTicks to avoid this effect: for MT4 it was implemented for candle events only, for MT5 it has two modes for locking tick's events and locking candle's events. If lock is enable then MtApi expert is waiting after sending event until it will receive command UnlockTicks from client side. For MT4 version I have created ticket #226 and I will update MtApi with lock of ticks soon (will be same as MT5 version).

The lock of events is working for backtesting mode only.

eabase commented 3 years ago

Perfect answer. Thank you.