Strategy tester shows market closed when it is open

 

Making backtests suddenly the result changed a lot from one test to the other.

Looking for the reason why, it shows that it shows suddenly Market closed at a time when in tests before trades were made:

2024.10.27 15:52:01.560 2020.01.03 22:48:40   failed market buy 4 .USTECHCash, close #7 sell 4 .USTECHCash 8801.2 [Market closed]

In the tests before it closed the orders without items at that time.

How can it be, that suddenly the tester shows Market closed at a time when the market is open?

It closes at 23:14:59


Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
All requests to execute trade operations are sent as a structure of a trade request MqlTradeRequest using function OrderSend() . The function...
 
Heiko Kendziorra:

Making backtests suddenly the result changed a lot from one test to the other.

Looking for the reason why, it shows that it shows suddenly Market closed at a time when in tests before trades were made:

2024.10.27 15:52:01.560 2020.01.03 22:48:40   failed market buy 4 .USTECHCash, close #7 sell 4 .USTECHCash 8801.2 [Market closed]

In the tests before it closed the orders without items at that time.

How can it be, that suddenly the tester shows Market closed at a time when the market is open?

It closes at 23:14:59


Probably it's somehow related to the fact that your broker switched off DST mode in its time zone at the night between 26 and 27, actually deducting 1 hour.

 
Heiko Kendziorra:

Making backtests suddenly the result changed a lot from one test to the other.

Looking for the reason why, it shows that it shows suddenly Market closed at a time when in tests before trades were made:

2024.10.27 15:52:01.560 2020.01.03 22:48:40   failed market buy 4 .USTECHCash, close #7 sell 4 .USTECHCash 8801.2 [Market closed]

In the tests before it closed the orders without items at that time.

How can it be, that suddenly the tester shows Market closed at a time when the market is open?

It closes at 23:14:59

This is because the current daylight savings changed this weekend, and the broker probably updated the contract specifications accordingly.

There is no historical data for the contract specifications, so the Strategy Tester uses the current contract specifications of the entire test.

Any tests carried out before the contract specifications were update, were run with the previous version of the specifications.

However, you can customise the specifications to your own choosing ...




 
Stanislav Korotky #:

Probably it's somehow related to the fact that your broker switched off DST mode in its time zone at the night between 26 and 27, actually deducting 1 hour.

Thanks. Yes, that should be the reason. Seems the broker made the change this afternoon. Just it would be a big error if the effect stays like it is now.

The clock in Market watch is stopped now. I hope when trading and the clock start again the error is fixed. 

 
Heiko Kendziorra #: Thanks. Yes, that should be the reason. Seems the broker made the change this afternoon. Just it would be a big error if the effect stays like it is now. The clock in Market watch is stopped now. I hope when trading and the clock start again the error is fixed. 

It seems you did not read the posts properly. The "error" will NOT be fixed. It will remain that way until March of 2025 when the DST changes again.

Read my post again, and set your own sessions according to your test requirements.

 
Fernando Carreiro #:

This is because the current daylight savings changed this weekend, and the broker probably updated the contract specifications accordingly.

There is no historical data for the contract specifications, so the Strategy Tester uses the current contract specifications of the entire test.

Any tests carried out before the contract specifications were update, were run with the previous version of the specifications.

However, you can customise the specifications to your own choosing ...

Thanks! That did the job.  

 
Fernando Carreiro #:

It seems you did not read the posts properly. The "error" will NOT be fixed. It will remain that way until March of 2025 when the DST changes again.

Read my post again, and set your own sessions according to your test requirements.

I sent my reply before I saw your post, now it's clear.

 
Fernando Carreiro #:

Read my post again, and set your own sessions according to your test requirements.

This will not completely remove the problem, but rather hide it a bit, because the changed sessions will affect also previous history of quotes where summer time was active and sessions should close earlier. In other words, the test will now produce trades where it would normally show the error [market closed].

 
@Stanislav Korotky #: This will not completely remove the problem, but rather hide it a bit, because the changed sessions will affect also previous history of quotes where summer time was active and sessions should close earlier. In other words, the test will now produce trades where it would normally show the error [market closed].

Yes, I know. That is why I stated that it should be set according to the test requirements, for example if the test is broken up into semesters.

For a more complete solution, one would need to include a DST and session time compensation in the EA itself.

 
Fernando Carreiro #:

Yes, I know. That is why I stated that it should be set according to the test requirements, for example if the test is broken up into semesters.

For a more complete solution, one would need to include a DST and session time compensation in the EA itself.

You wrote, that the "error" (your quotes) will not be fixed, so I take it you consider this is not an error, but it's apparently a flaw in the tester, which would be better to fix along with some other issues known for years.

It's not normal, imho, to plug a bunch of tweaks in every MQL source code to overcome different inconsistencies in the platform. The platform should be fixed itself.

 
@Stanislav Korotky #:

You wrote, that the "error" (your quotes) will not be fixed, so I take it you consider this is not an error, but it's apparently a flaw in the tester, which would be better to fix along with some other issues known for years.

It's not normal, imho, to plug a bunch of tweaks in every MQL source code to overcome different inconsistencies in the platform. The platform should be fixed itself.

Yes, I don't consider it an "error" in the sense that the OP described, because he believed it would be fixed once the markets opened again.

However, I do consider it a design flaw by MetaQuotes, because they don't have built-in support for handling time-zones and daylight-savings changes. They don't even have a history of changes to the contract specifications.

So I do consider it bad design and poor implementation by MetaQuotes, but I don't believe they will ever fix it. They tend to focus on adding new functionality, but do little to fix or improve the robustness of the MetaTrader components.