Symbol.MarketHours not working in backtest
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
algobeginner
24 Dec 2024, 16:17
How about use your own historical data to emulate this factor ?
@algobeginner