Error [Market Closed] when backtesting in MT5 on a custom symbol

 

Hi All,

I am using MT5 on a demo account. I've created a custom symbol (EURUSD.custom), imported the same settings of EURUSD. imported 1 min bar data and tick data.

When  backtesting any EA (Simple MA cross), whenever I reach OrderSend() function, it through the error "failed market sell 0.01 EURUSD.custom [Market closed]". the EA runs properly, bars are formed, rates are copied,signals are generated, it is only when trying to send a market order.

I would really appreciate the support.

Regards


"

 
abbasakh:

Hi All,

I am using MT5 on a demo account. I've created a custom symbol (EURUSD.custom), imported the same settings of EURUSD. imported 1 min bar data and tick data.

When  backtesting any EA (Simple MA cross), whenever I reach OrderSend() function, it through the error "failed market sell 0.01 EURUSD.custom [Market closed]". the EA runs properly, bars are formed, rates are copied,signals are generated, it is only when trying to send a market order.

I would really appreciate the support.

Regards


"

Probably, https://www.mql5.com/en/forum/219437
market is closed error
market is closed error
  • 2017.11.11
  • www.mql5.com
I'm getting this in weekdays and have put my codes inside if(IsTradeAllowed()) but my EA is still trying to open/close a trade I've seen some post...
 
I am getting the error during backtesting and not live tradng.
 
Same happening to me here!! If you solved this, please help me... Custom Symbols on metatrader are so bugged!!!
 
abbasakh:

Hi All,

I am using MT5 on a demo account. I've created a custom symbol (EURUSD.custom), imported the same settings of EURUSD. imported 1 min bar data and tick data.

When  backtesting any EA (Simple MA cross), whenever I reach OrderSend() function, it through the error "failed market sell 0.01 EURUSD.custom [Market closed]". the EA runs properly, bars are formed, rates are copied,signals are generated, it is only when trying to send a market order.

I would really appreciate the support.

Regards


"

I've got a similar issue but with trading equity CFD and only for backtests before 2016 or 2008 depending on which broker I use..

The strange thing is that a few days ago, everything worked just fine and I was able to backtest back to 1990.

 
Pieter Mergenthaler:

I've got a similar issue but with trading equity CFD and only for backtests before 2016 or 2008 depending on which broker I use..

The strange thing is that a few days ago, everything worked just fine and I was able to backtest back to 1990.

Search the forum first before posting! You would have found out that the newer builds of MetaTester 5, now also take into account the session times for a symbol and will prevent out-of-session trading and report an error, as if it were a real live situation. It is a more realistic simulation now in regards to session times.

 

I got this issue too. The issue is indeed what Fernando Carreiro has mentioned. 

This is how I solve it:

I am backtesting EURUSD using daily timeframe, and its trading session is Monday to Thursday 00:01-23:59 and Friday 00:01-23:55.

Since the trade time starts from 00:01, I can't set Expert_EveryTick=false because it always tries to send order at 00:00 when a new daily bar forms.

Thus, i set Expert_EveryTick=true, and then handle the signal generation once every daily bar in my custom Signal Module. 

Of course, you can try to mess around with the trading session by double clicking on the trading session time in the symbol. 

 
Pieter Mergenthaler:

I've got a similar issue but with trading equity CFD and only for backtests before 2016 or 2008 depending on which broker I use..

The strange thing is that a few days ago, everything worked just fine and I was able to backtest back to 1990.

Please read 

https://www.mql5.com/en/forum/369755


May helpful 

Please help - "Market closed" in Strategy Tester
Please help - "Market closed" in Strategy Tester
  • 2021.05.21
  • www.mql5.com
Hi everybody, like always and done without any problems in previous versions of MT5 I want to test my (unmodified) EA by the strategy tester...
 

Hi Everyone,


I am also getting this error when backtesting and can see the problem.


My broker has these times:


The issue occurs when a trade attempt is made at 00:00. How is it best to handle this?  If I disallow trading out of hours then it will mess up the signals.

So I'm thinking about just queuing the order until I can trade? Is that the best way of doing it?


Cheers,


Ed

 

This is your choice, you can ignore signals when the market is close, or delay them (queue), or whatever you find as "best" way.

 
Alain Verleyen #:

This is your choice, you can ignore signals when the market is close, or delay them (queue), or whatever you find as "best" way.

Thanks Alain,


Seems a bit of a pain in the back side that the quote period is different to the trading period. Especially if trading the daily time frame as a new candle will be generated at 00:00 but you wont be able to make a trade at that point. So all trades will be delayed.