[B135] Different results between SQX <-> MT5 with tick data if using HMA or DEMA for pending order prices

If the Hull Moving Average or the DEMA is used for pending order entry prices (Stop / Limit) like this:


Open Long order at (HullMovingAverage(Main chart,HullMovingAvrPrd2, PRICE_OPEN)[HullMovingAverageShf] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;

or


Open Long order at (DEMA(Main chart,DEMAPeriod,DEMAAppliedPrice) [DEMAShift] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;



...the tick-data backtests don´t match up between SQX <-> MT5 for the entries (using tick-data exported from MT5 and imported to SQX, so exactly the same data). The limit orders are off by ~2 or more pips compared to SQX every time and hence also end in totally different trades.

If not using the HMA or DEMA, but for example KAMA instead, the backtests match up 100%, down to the point.

Update: I´ve made some more tests. If using the HMA for entry pricing of pending orders (Limit orders in this case) and comparing the tick-data backtests to MT5 (of course using the same tick-data), each entry is off by about +1.2 to +1.6 pips in the MT5 backtests. It deviates, but always in the 1.2 to 1.6 pips range. I think this really shows that the MT5 implementation of the HMA is calculated slightly differently from the one in SQX, which then creates these differences. If I take that strategy and simply switch it out for a SMA instead the HMA, everything matches up to the point, 100%. So if you could possibly make the HMA in MT5 to match the SQX implementation, that would be highly appreciated.

Update 2 (HMA fixed): I was able to fix the issue with the HMA by replacing the MT5 version with the latest one from https://www.mql5.com/en/code/25257 Now the backtests match 100% too, great ???? I´ve attached it, it can simply replace the SqHullMovingAverage.mq5 and the backtests between SQX and MT5 will match then ????
Attachments
  • Votes +7
  • Project StrategyQuant X
  • Type Bug
  • Status New
  • Priority Normal

History

g
#1

geektrader

10.02.2022 10:28

Task created

g
#2

geektrader

10.02.2022 10:28
Voted for this task.
b
#3

bentra

10.02.2022 17:20
Voted for this task.
g
#4

geektrader

11.02.2022 04:59

Subject changed from [B135] Different results between SQX <-> MT5 with tick data if using HMA for pending order prices to [B135] Different results between SQX <-> MT5 with tick data if using HMA or DEMA for pending order prices

g
#5

geektrader

11.02.2022 05:00

Description changed:

If the Hull Moving Average or the DEMA is used for pending order entry prices (Stop / Limit) like this:


Open Long order at (HullMovingAverage(Main chart,HullMovingAvrPrd2, PRICE_OPEN)[HullMovingAverageShf] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;

or


Open Long order at (DEMA(Main chart,DEMAPeriod,DEMAAppliedPrice) [DEMAShift] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;



...the tick-data backtests don´t match up between SQX <-> MT5 for the entries (using tick-data exported from MT5 and imported to SQX, so exactly the same data). They are off by ~2 pips every time. If not using the HMA or DEMA, but another MA instead, the backtests match up 100%.

g
#6

geektrader

11.02.2022 05:40

Description changed:

If the Hull Moving Average or the DEMA is used for pending order entry prices (Stop / Limit) like this:


Open Long order at (HullMovingAverage(Main chart,HullMovingAvrPrd2, PRICE_OPEN)[HullMovingAverageShf] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;

or


Open Long order at (DEMA(Main chart,DEMAPeriod,DEMAAppliedPrice) [DEMAShift] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;



...the tick-data backtests don´t match up between SQX <-> MT5 for the entries (using tick-data exported from MT5 and imported to SQX, so exactly the same data). The limit orders are off by ~2 or more pips compared to SQX every time and hence also end in totally different trades.

If not using the HMA or DEMA, but for example KAMA or TEMA instead, the backtests match up 100%, down to the point.

g
#7

geektrader

12.02.2022 05:21

Description changed:

If the Hull Moving Average or the DEMA is used for pending order entry prices (Stop / Limit) like this:


Open Long order at (HullMovingAverage(Main chart,HullMovingAvrPrd2, PRICE_OPEN)[HullMovingAverageShf] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;

or


Open Long order at (DEMA(Main chart,DEMAPeriod,DEMAAppliedPrice) [DEMAShift] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;



...the tick-data backtests don´t match up between SQX <-> MT5 for the entries (using tick-data exported from MT5 and imported to SQX, so exactly the same data). The limit orders are off by ~2 or more pips compared to SQX every time and hence also end in totally different trades.

If not using the HMA or DEMA, but for example KAMA instead, the backtests match up 100%, down to the point.

Update: I´ve made some more tests. If using the HMA for entry pricing of pending orders (Limit orders in this case) and comparing the tick-data backtests to MT5 (of course using the same tick-data), each entry is off by about +1.2 to +1.6 pips in the MT5 backtests. It deviates, but always in the 1.2 to 1.6 pips range. I think this really shows that the MT5 implementation of the HMA is calculated slightly differently from the one in SQX, which then creates these differences. If I take that strategy and simply switch it out for a SMA instead the HMA, everything matches up to the point, 100%. So if you could possibly make the HMA in MT5 to match the SQX implementation, that would be highly appreciated ????

g
#8

geektrader

12.02.2022 05:22

Description changed:

If the Hull Moving Average or the DEMA is used for pending order entry prices (Stop / Limit) like this:


Open Long order at (HullMovingAverage(Main chart,HullMovingAvrPrd2, PRICE_OPEN)[HullMovingAverageShf] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;

or


Open Long order at (DEMA(Main chart,DEMAPeriod,DEMAAppliedPrice) [DEMAShift] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;



...the tick-data backtests don´t match up between SQX <-> MT5 for the entries (using tick-data exported from MT5 and imported to SQX, so exactly the same data). The limit orders are off by ~2 or more pips compared to SQX every time and hence also end in totally different trades.

If not using the HMA or DEMA, but for example KAMA instead, the backtests match up 100%, down to the point.

Update: I´ve made some more tests. If using the HMA for entry pricing of pending orders (Limit orders in this case) and comparing the tick-data backtests to MT5 (of course using the same tick-data), each entry is off by about +1.2 to +1.6 pips in the MT5 backtests. It deviates, but always in the 1.2 to 1.6 pips range. I think this really shows that the MT5 implementation of the HMA is calculated slightly differently from the one in SQX, which then creates these differences. If I take that strategy and simply switch it out for a SMA instead the HMA, everything matches up to the point, 100%. So if you could possibly make the HMA in MT5 to match the SQX implementation, that would be highly appreciated.

g
#9

geektrader

12.02.2022 05:38

Description changed:

If the Hull Moving Average or the DEMA is used for pending order entry prices (Stop / Limit) like this:


Open Long order at (HullMovingAverage(Main chart,HullMovingAvrPrd2, PRICE_OPEN)[HullMovingAverageShf] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;

or


Open Long order at (DEMA(Main chart,DEMAPeriod,DEMAAppliedPrice) [DEMAShift] - (PriceEntryMult * ATR(Main chart,ATRPeriod)[ATRShift])) Limit;



...the tick-data backtests don´t match up between SQX <-> MT5 for the entries (using tick-data exported from MT5 and imported to SQX, so exactly the same data). The limit orders are off by ~2 or more pips compared to SQX every time and hence also end in totally different trades.

If not using the HMA or DEMA, but for example KAMA instead, the backtests match up 100%, down to the point.

Update: I´ve made some more tests. If using the HMA for entry pricing of pending orders (Limit orders in this case) and comparing the tick-data backtests to MT5 (of course using the same tick-data), each entry is off by about +1.2 to +1.6 pips in the MT5 backtests. It deviates, but always in the 1.2 to 1.6 pips range. I think this really shows that the MT5 implementation of the HMA is calculated slightly differently from the one in SQX, which then creates these differences. If I take that strategy and simply switch it out for a SMA instead the HMA, everything matches up to the point, 100%. So if you could possibly make the HMA in MT5 to match the SQX implementation, that would be highly appreciated.

Update 2 (HMA fixed): I was able to fix the issue with the HMA by replacing the MT5 version with the latest one from https://www.mql5.com/en/code/25257 Now the backtests match 100% too, great ???? I´ve attached it, it can simply replace the SqHullMovingAverage.mq5 and the backtests between SQX and MT5 will match then ????

Attachment SqHullMovingAverage.mq5 added

SqHullMovingAverage.mq5
(12.65 KiB)
E
#10

Emmanuel

12.02.2022 06:36
Voted for this task.
g
#11

geektrader

13.03.2022 16:14

Just a little update, using DEMA the problem persists, it´s calculated slightly differently in SQX and MT5. If using it as a profit target (TP), it´s easiest to see that DEMA is always off by about 0.3 to 1 pip between SQX and MT5.


The HMA I´ve fixed in MT5 (see attachment above), is all good now, everything matches.

g
#12

geektrader

14.03.2022 01:49
Another update: @clonex (SQX Programming)#2203  I think I´ve found the issue. DEMA allows being calculated on Close / Open / High / Low, as I can see in your Java code. However, the SQDema.mq5 always calculates it on CLOSE, there isn´t even a parameter where you are overhanding which price to apply for the DEMA. See SQDema.mq5 and how you call it from the generated code:


indicatorHandles[DEMA_1] = iCustom(NULL,0, "SqDEMA", DEMAPeriod, 2);



The 2 at the end is the shift, you are not handing over the applied price anywhere, the indicator does not even take that as an input variable at all the way it is coded now, so it will always be applied to CLOSE while in SQX it can have any of the above-mentioned prices.
b
#13

bentra

14.03.2022 01:58
Thanks @geektrader 
g
#14

geektrader

14.03.2022 02:09

I´ve tried replacing it with "iDEMA(NULL, 0, DEMAPeriod, 2, PRICE_HIGH)" in the MQL5 code, to assign the correct PRICE enumeration like the SQX strategy that I use uses it (HIGH), but even then the backtests don´t match while they do if using other MA indicators in SQX. There must be more issues between how this is implemented between SQX and MT5, but I am giving up for now and hope this get´s addressed by your coders. Thanks a lot.


P.S.: Additionally, here is one more bug: if 2 DEMA´s are used in one strategy in SQX, the variable DEMAAppliedPrice is always the same for all DEMA´s, it´s not being enumerated like the DEMAPeriod (e.g. DEMAPeriod2), etc.

CG
#15

Chris G

14.03.2022 16:07
Voted for this task.
o
#16

Enric

19.03.2022 12:15
Voted for this task.
b
#17

bentra

10.05.2022 17:55
Thanks for the Hull fix, worked like a charm.
Cc
#18

Cyber

22.05.2022 02:35
Voted for this task.
IH
#19

clonex / Ivan Hudec

04.08.2022 14:48

Attachment SqHullMovingAverage.mq5 added

SqHullMovingAverage.mq5
(12.66 KiB)

Here is a fixed version of indicator SqHullMovingAverage.mq5

Fs
#20

Fortunate

11.09.2022 17:49
Voted for this task.
g
#21

geektrader

03.02.2023 00:31

Attachment Untitled.png added

Untitled.png
(292.57 KiB)

Unfortunately, the DEMA is still completely wrong calculated between SQX and MT5. Only the HMA has been fixed. Please fix the DEMA as well. Thanks.


P.S.: I´ve attached a screenshot of a strategy that uses DEMA for the entry price of LIMIT orders. There is no match between SQX and MT5 using the exact same tick-data / time range. If exchanging DEMA for EMA, HMA, etc., the backtests match up perfectly.

g
#22

geektrader

03.02.2023 00:38

Attachment Untitled.png added

Untitled.png
(311.19 KiB)
This is the exact same strategy as above, just DEMA switched out for EMA for the limit orders. Now it´s a perfect match of the backtests between SQX and MT5. Clearly shows that DEMA is the issue and is not fixed.
TV
#23

Tomas Vanek

03.02.2023 16:37

Anything that uses the DEMA indicator leads to incorrect backtests in MT5. The results between your DEMA implementation in SQX and MT5 are not coherent. It's calculated differently in SQX than in the MT5 implementation. Hence no backtest will match between SQX and MT5 if the DEMA indicator is used somewhere in a strategy. This applies for all strategies. 

The same problem existed for the HMA indicator which was also part of this bug report. But the HMA was fixed and the bug closed. Someone forgot to also fix the DEMA issue.


g
#24

Lee Guan Chuan

06.02.2023 05:33

Status changed from In progress to Waiting for information

Attachment Capture.jpg added

Capture.jpg
(53.98 KiB)
Hi,


I have checked our SQX and couldn't find DEMA.

If you could provide me where you download and import the DEMA. I can check it.


Thanks.


Votes: +7

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please