Troubles when backesting with [Market closed] error.

 

Dear people,


After having read several times the other thread, I am fighting for understanding what's wrong in my backtesting.


Let's say that I want to test a strategy on EURUSD, daily bars, using 1 minute OHLC precision.


On my broker's (Darwinex) platform, market times for this instrument are:

(Thus, if I read 00:01-24:00 as "always" correctly, there should be no interruptions also during the night, or eventually there will be no trade allowed between 00:00 (24:00) and 00:01).


Now, let's come to 2010.03.15, at new daily bar, when I would like to open a trade. This is what my history center shows me as quote for the M1 bars:

And in my code, the safety statement

datetime now = TimeCurrent();
MqlDateTime my_time;
TimeToStruct(now, my_time);
//debug
printf("Time current is %s", TimeToString(now, TIME_DATE|TIME_MINUTES));
printf("Is trade allowed? %s", (string)SymbolInfoSessionTrade(a_.Symbol(), (ENUM_DAY_OF_WEEK)my_time.day_of_week, 0, now, now));

... gives me a sound "Is trade allowed? TRUE" for 2010.03.15 00:00. (Code is part of a large library. a_.Symbol() gives back a nice "EURUSD", I can ensure you). (And.. to be clear: in the library if the above statement gives FALSE, there would be a lot of routines for stopping OrderSend to be fired).


Then... given all the above. Can anybody explain me why (why? why? why?) the Expert is stopped with this nice log statement:

JE      2       13:53:59.957    Trades  2010.03.15 00:00:00   failed market sell 0.1 EURUSD [Market closed]


Of course... within the large library it is easy to avoid such mistakes by using a good time filter inhibiting trading between for instance 23:30 and 00:30 every day (when spreads are also terrible... by the way). And anyway, in real trading, these things will not happen because, if the market is closed, no tick will come in and no OnTick event will be handled in the meanwhile. But anyway... I would like to understand... 

(March 15th 2010 is a Monday, by the way. And the above statement of course gives FALSE when interrogated with a timestamp which is "clearly" outside market hours like on Saturday or Sunday early afternoon...)

Making things completely flexible is in principle a good thing. But making something so flexible that finally it becomes difficult (or impossible) to use is not a positive thing. Sometimes mql5/MT5 compared to mql4/MT4 seems like a Ferrari compared to a KIA (no pun intended). But the seller of the KIA gives you a car with a key and wishes you a nice drive. The Ferrari seller gives you a huge box with all the components, gives you a blueprint, and then wishes you a nice trip (...after you manage to put together a vehicle by yourslef).


Best regards and thank you in advance.

Scopri le nuove opportunità di MetaTrader 5 con la community e i servizi MQL5
Scopri le nuove opportunità di MetaTrader 5 con la community e i servizi MQL5
  • www.mql5.com
MQL5: il linguaggio delle strategie di trading integrato nella piattaforma di trading MetaTrader 5 permette di creare i propri robot di trading, indicatori tecnici, script e librerie di funzioni
 
No hints on this?
 
Fab #:
No hints on this?

Hints about what ? The symbol setting clearly shows that trading is disabled Monday from 00:00 to 00:05. Your way to check SymbolInfoSessionTrade() is incorrect, search on the forum for the good way to do it.

It was not the case in 2010 and that's why you have rates and ticks, but there is no history on the symbol settings so you are stuck with the current one.

 

Why do I get similar errors with these sessions?


This is for a custom symbol.

Files:
Reason: