- If the backtest is bad, will the EA be bad in live trading?
- RSI indicator
- Scripts and chart change
It should work reasonably correctly when testing with every tick.
That is a not so very well-known terminal bug and it may happen not only in the tester but on demo servers too. It is documented here:
https://github.com/rosasurfer/mt4-mql/issues/10
There is also a workaround but unfortunately it requires manual coding.
Surprisingly the bug is already more than 12 years old and until now nobody seems to have cared about it.
![Tester & demo servers execute only one limit per ticket and tick · Issue #10 · rosasurfer/mt4-mql Tester & demo servers execute only one limit per ticket and tick · Issue #10 · rosasurfer/mt4-mql](https://c.mql5.com/36/32/tester-demo-servers-execute-only.png)
- rosasurfer
- github.com
SL/TP are respected also if EA tested with open prices only mode.
You have a different issue, it's also so strange that order get executed and closed with loss in the same exact moment (2011.12.20 00:00)
SL/TP are respected also if EA tested with open prices only mode.
You have a different issue, it's also so strange that order get executed and closed with loss in the same exact moment (2011.12.20 00:00)
You are wrong. As it is described in the ticket: Only one limit per ticket and tick is executed.
(1) If a pending entry order has a SL atttached and both limits are triggered by the same tick the entry limit is executed and the SL is not (one
limit check per tick only, the open position is invalid and this by itself is already a broken implementation).
(2) If the next tick doesn't trigger the SL the limit is not executed again (the open position stays invalid). Worse: By now the terminal has
"forgotten" about the SL ever been hit.
(3) If it now happens that the market continous to go in the direction of the wrongly open position without hitting the SL a second time the
position stays open until the end of the test. Of course the whole test is invalid.
That is exactly what OP observed.
Cause of the bug is the terminal only checking a single limit per ticket and tick. If more limits are triggered (max 2) the second is ignored and not executed.
Workaround: If you use pending orders with SL you have to manually monitor the ticket for execution. On the execution tick (only on that tick) you need to check whether the SL was triggered too (price comparison). If it was triggered you have to execute the SL manually by using OrderClose() as the terminal will not do it.
The screenshot shows a Buy Limit at 1439.27 with SL at 1438.17, both triggered by a single tick down to 1437.16 (a news spike). The position was
opened but the SL was not executed because it happened during a single tick. The SL had to be executed manually.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use