Symbol.MarketHours not working in backtest

Created at 23 Dec 2024, 19:18
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ST

stefan1

Joined 09.11.2016

Symbol.MarketHours not working in backtest
23 Dec 2024, 19:18


Hello,

in my Cbot I do the following check to only place orders if the market is open:

bool marketIsOpen = Symbol.MarketHours.IsOpened();      // Check if the market is open

Obviously, I want to make sure that the backtest behaves the same as if the Cbot would run in real time. Unfortunately I read this in the forum:

“Please note that Symbol.MarketHours provides the current market hours for the symbol and not historical information.”

This confirms my finding when backtesting. Backtest seems to use the Symbol.MarketHours of the week in which I start the backtest. Compared to regular trading weeks, this week has a holiday on Wednesday. Consequently my backtesting results are totally off from what they should be (i.e. when I start the backtest in a regular trading week).

Is there anything to deal with this issue?

Thanks and best regards,

Stefan


@stefan1
Replies

algobeginner
24 Dec 2024, 16:17

How about use your own historical data to emulate this factor ?


@algobeginner