Strategy tester and market close scenarios

 

I've been using an specific broker for not that long, like 5 months. I've developed my own EA and until a few weeks ago I noticed every now and then, not always, during my backtesting I would see ticks starting at 13:00 hours but the Symbol Specification in MT always showed quotes and trading starting Mon-Fri 1400. So I just thought Mr @Fernando Carreiro was right when they said: 

> Just because there are ticks during a certain period that does not mean that a broker allows trading during that period.

in here: https://www.mql5.com/en/forum/369755#comment_22461818


and live moved on, I added a check in my EA to get the session trading hours by calling SymbolInfoSessionTrade() and would not place trades before 13:00 as the symbol spec showed trades starting at 14:00. As suggested by the other guru in this forum(@Alain Verleyen) here: https://www.mql5.com/en/forum/377165#comment_24494019


Well, everything changed recently with DST in the place where my broker is located and now if I right click the same symbol in the Market Watch, Specs, the trades start at 13:00 hours, no longer 14:00. 


So I have two problems now:


  1. A friend of mine is running BT using my EA and they see orders being placed starting 13:00. I believe this has to do with Strategy Tester looking at the trading hours of the symbol right now and applying that throughout all the test. So if in the Market Watch, symbol, right now, it says it starts at 13:00 then if there are ticks starting at 13:00 there is a possibility of orders being placed. Which is a problem because if my friend would run the exact same BT a few weeks ago(before my broker change the symbol trading time), there would be no trades before 14:00, because I believe ST will use the current trading hour sessions on the symbol and apply it during the whole BT.
  2. My own MT5 instances still believes the trading session for this given symbol starts at 14:00, even though I see 13:00 when I right click the symbol in the Market Watch, Specifications. This seems to be a caching problem as I was able to resolve it by deleting everything under the Bases folder in the data folder.


Problem number #1 is what really concerns me. is it correct that MT5 during BT will use the current symbol trading hours as the truth about trading hours? If so, is there any way to get consistent backtests? In case the problem is still not clear let me explain it:


The symbol I'm working on usually starts trading at 14:00 hours. But during some part of the year it starts at 13:00 hours. This is according to the Symbol Specs in MT5. Now, if right now, I would run a BT back in 2020 when the trading hours started at 13:00 I would see orders being placed 13:00 onwards. Let's just say I would see 10 trades in a single day in 2020. Now, eventually my broker will change the symbol trading hours again to 14:00 and if then I run the same BT, on the same date, my EA would get Market Closed errors if it would try to place an order before 14:00. So in that same day I would see less than 10 orders. 


It seems to me that the only way to have a reliable BT is to run it during the time of the year when the trading hours are equal or greater than trading hours in the past. Does that make sense?

Please help - "Market closed" in Strategy Tester - MT5 backtesting the Dow Jones with tick data: Is it possible to "shift the time stamp of the tick data for one hour
Please help - "Market closed" in Strategy Tester - MT5 backtesting the Dow Jones with tick data: Is it possible to "shift the time stamp of the tick data for one hour
  • 2021.05.21
  • www.mql5.com
Concerning backtesting the dow jones with tick data: there is no trading session between 00:00 am and 01:00 am: but there are ticks between 00:00 and 01:00 am. I think the timestamp of the tick data has different time offset than the symbol, correct. Is it possible to "shift" the time stamp of the tick data for one hour
 

MetaTrader does not have historical records for the session times nor DST nor time-zone changes.

The Strategy Tester always uses the current DST and the session times as reported in the current contract specifications for the entire test period.

Forum on trading, automated trading systems and testing trading strategies

TimeDaylightSavings Doesn't Work On Backtesting

Fernando Carreiro, 2023.11.12 11:48

There are limitations when simulating time in the Strategy Tester. No historical records are kept for time-zone and daylight savings, so they cannot be simulated.

 

You can however, adjust the test contract specification in the Strategy Tester to your own liking ...


 
Fernando Carreiro #:

You can however, adjust the test contract specification in the Strategy Tester to your own liking ...


wasn't aware of that. thank you. that helps.