Backtesting but market closed on order execution.

 

Hi,

I wanted to test my strategy on stock and had to changed the demo account, using VantageFX-demo account.

Had to switch the filling_type to SYMBOL_ORDER_MARKET and then I got the "Market closed" error on order execution. With other order types is got "unsupported filling type".

I can't seem to find an explanation to why is it actually trying to execute the order on the account?  As all I need is to use the demo account for data. Am I missing some checkbox to tell backtester to simulate the orders?

Best Regards,

Hendrik

 
lastpunisher:

Hi,

I wanted to test my strategy on stock and had to changed the demo account, using VantageFX-demo account.

Had to switch the filling_type to SYMBOL_ORDER_MARKET and then I got the "Market closed" error on order execution. With other order types is got "unsupported filling type".

I can't seem to find an explanation to why is it actually trying to execute the order on the account?  As all I need is to use the demo account for data. Am I missing some checkbox to tell backtester to simulate the orders?

Best Regards,

Hendrik

The Strategy Tester of course doesn't try to open real orders. If you get market close error that's because you are trying a trading operation when the market is closed according to trading hours (with ST simulated time). Check your symbol settings and fix your code accordingly.

 
Alain Verleyen:

The Strategy Tester of course doesn't try to open real orders. If you get market close error that's because you are trying a trading operation when the market is closed according to trading hours (with ST simulated time). Check your symbol settings and fix your code accordingly.

Makes sense, tho I can't seem to find a sensible way to change the session time. Original symbol did not allow me to set the session time values.

I tried to make a custom symbol which allows changing session time, used AAPL. Then I exported original AAPL data and imported to my custom AAPL2 symbol. When I try to use the custom symbol then it is not able to find the data, tho I double checked that I got the correct timeframe.

There must be a simpler way?

 
lastpunisher: Makes sense, tho I can't seem to find a sensible way to change the session time. Original symbol did not allow me to set the session time values.
You are not supposed to change the session times. Your EA is supposed to read the session times and not trade at all during those periods, not even to place pending orders.
 

Yes, but I need backtesting to be able to simulate the orders, even in the weekend.

Actually, I would expect the backtester not to be affected by the session time at all, as it is not going to do any trades on the live market anyway.

When I use the MetaQuotes-Demo account and do backtesting on currencies, even in the weekend, everything works out of the box, but when I try to use VantageFX-demo account for stock data, then it says Market Closed and backtester does not do any trades.

 
Could there be differences between MT4 and MT5? I'm on MT5 atm.
 
lastpunisher: Yes, but I need backtesting to be able to simulate the orders, even in the weekend. Actually, I would expect the backtester not to be affected by the session time at all, as it is not going to do any trades on the live market anyway. When I use the MetaQuotes-Demo account and do backtesting on currencies, even in the weekend, everything works out of the box, but when I try to use VantageFX-demo account for stock data, then it says Market Closed and backtester does not do any trades.

You can back test on weekends or anytime you want, but the Strategy Tester does not use the Live Time, but the simulated testing time based obviously on Quotes Session Times, of which there are simulated Trade Session Times that your EA has to check and adhere to, as if it were trading on a live account.

Obviously, different brokers and different account types and different symbols use different Quotes and Trade Session Times.

This subject has already been discussed several times here on the forum, so please do a search and read up on the other threads as well.

 

Forex time and Backtest operations during Weekends - https://www.mql5.com/en/forum/371144

Please help - "Market closed" in Strategy Tester - https://www.mql5.com/en/forum/369755

 
lastpunisher:

Yes, but I need backtesting to be able to simulate the orders, even in the weekend.

Actually, I would expect the backtester not to be affected by the session time at all, as it is not going to do any trades on the live market anyway.

When I use the MetaQuotes-Demo account and do backtesting on currencies, even in the weekend, everything works out of the box, but when I try to use VantageFX-demo account for stock data, then it says Market Closed and backtester does not do any trades.

You are still mixing live chart/trading and the Strategy Tester which is completely simulated trading. However the Strategy Tester by default use the same settings as the real ones. You get the "Market close" error because on a live trading you would get the same error at that given time.

FIX YOUR CODE.

Reason: