Generated a strategy (attached MQ4 and SQX) which uses a fixed SL and TP as the only exit type. This runs using GBP/USD on H1. Tickdata shifted to GMT+2 with US DST to align with New York.
Backtest in SQX is fine, however using Dukascopy data using TDS to backtest the strategy, it fails at the point the real spread is more than the stop loss.
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: - SQ LOG 2016.12.26 00:04 Warning! Cannot delete order and Sl/PT was not set! Error: 4108
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: OrderDelete error 4108
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: market order #159 cannot be deleted
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: - SQ LOG 2016.12.26 00:04 Cannot set SL / PT for this order, deleting it!
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: - SQ LOG 2016.12.26 00:04 Cannot modify SL, it cannot be closer than minimum allowed: 1.04565 > 1.04416
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: - SQ LOG 2016.12.26 00:04 Modifying order with ticket: 159, SL: 1.04565 and PT: 1.04815
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: open #159 buy 12.00 GBPUSD at 1.04665 ok
2020.02.16 15:21:21.587 2016.12.26 00:04:01 Strategy 0.134502 GBPUSD,H1: - SQ LOG 2016.12.26 00:04 Opening order type BUY with price 1.04665. Current market prices: 1.04665 / 1.04416
Note at this point, the strategy fails in MetaTrader4 because we end up with a trade having no SL to TP, and therefore the trade simply remains open and stuck until the backtest completes!
I would suggest that the MQL4 should set the SL and TP size to the required calculated price, but if this fails due to the SL or TP price being inside the spread, then either set the SL to the closest price possible or close the Market Order immediately.
The code at the moment is trying to delete a market order, which is of course impossible.
As it is, the backtest of the strategy is completely different due to this one trade failing to set a SL and TP because every subsequent order is rejected because this order with no SL/TP is open.
2020.02.16 15:21:34.806 2017.04.26 00:00:00 Strategy 0.134502 GBPUSD,H1: - SQ LOG 2017.04.26 00:00 Order with these parameters already exists and duplicate trades are not allowed. Canceling order...
Thanks,
Mike
I am surprised that the spread is so high. The common spread on GBPUSD I am used to is just a few pips, in your case it appears to be over 20 pips.
A spread that high will have a highly negative impact on the results. What broker do you use?
As a fix to this issue I would set a fixed spread in SQ's Builder and Retester to match your broker's spread and develop strategies using these settings.
I you want to backtest your attached strategy, you can set MinimumSL and MinimumPT in the EA parameters to be higher than the symbol's spread.
But the backtesting results will be much different than in SQ.
Best regards,
Tomas
The result is that under real trading conditions the MT4 EA generated by SQX becomes stuck and useless. The is what you see in the MT4 log.
2020.04.16 07:35:40.536 2016.12.26 00:04:01 Strategy 0.134502 EURUSD,H1: - SQ LOG 2016.12.26 00:04 Warning! Cannot delete order and Sl/PT was not set! Error: 4108
2020.04.16 07:35:40.536 2016.12.26 00:04:01 Strategy 0.134502 EURUSD,H1: OrderDelete error 4108
2020.04.16 07:35:40.536 2016.12.26 00:04:01 Strategy 0.134502 EURUSD,H1: market order #159 cannot be deleted
2020.04.16 07:35:40.536 2016.12.26 00:04:01 Strategy 0.134502 EURUSD,H1: - SQ LOG 2016.12.26 00:04 Cannot set SL / PT for this order, deleting it!
2020.04.16 07:35:40.536 2016.12.26 00:04:01 Strategy 0.134502 EURUSD,H1: - SQ LOG 2016.12.26 00:04 Cannot modify SL, it cannot be closer than minimum allowed: 1.04566 > 1.04416
2020.04.16 07:35:40.536 2016.12.26 00:04:01 Strategy 0.134502 EURUSD,H1: - SQ LOG 2016.12.26 00:04 Modifying order with ticket: 159, SL: 1.04566 and PT: 1.04816
2020.04.16 07:35:40.536 2016.12.26 00:04:01 Strategy 0.134502 EURUSD,H1: open #159 buy 4.40 EURUSD at 1.04666 ok
After that point the EA stops trading and becomes useless with one hanging trade that has no SL or TP set.
2020.04.16 07:35:57.801 2017.03.20 00:00:19 Strategy 0.134502 EURUSD,H1: - SQ LOG 2017.03.20 00:00 Order with these parameters already exists and duplicate trades are not allowed. Canceling order...
2020.04.16 07:35:57.801 2017.03.20 00:00:19 Strategy 0.134502 EURUSD,H1: - SQ LOG 2017.03.20 00:00 Opening order type BUY with price 1.07357. Current market prices: 1.07357 / 1.07318
This repeats forever due to the stuck trade.
Please fix this logic in the MQ4 code!
SQX simulation engine has similar mechanism. Such orders are marked as "Deleted" close type. For attached strategy set high spread 200 :) and all orders will be marked as such.
The problem is that SQX engine will close the order during simulation while in live trading you got a different behavior.
I believe it's much bigger issue with error handling since SQX engine assumes successful execution while in reality execution might fail.
Status changed from New to Fixed