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
Replies
stefan1
27 Dec 2024, 19:31
( Updated at: 30 Dec 2024, 07:15 )
RE: Symbol.MarketHours not working in backtest
algobeginner said:
How about use your own historical data to emulate this factor ?
Hello and thanks for your reply. Unfortunately I don't have data other than those provided by the Ctrader charts. In case I manage to get other data, could you please explain what you mean by “emulate this factor”? Furthermore, do you know if Spotware has plans to fix this issue? Could someone from Spotware please comment here?
Thanks and best regards, Stefan
@stefan1
PanagiotisCharalampous
30 Dec 2024, 07:27
RE: RE: Symbol.MarketHours not working in backtest
stefan1 said:
algobeginner said:
How about use your own historical data to emulate this factor ?
Hello and thanks for your reply. Unfortunately I don't have data other than those provided by the Ctrader charts. In case I manage to get other data, could you please explain what you mean by “emulate this factor”? Furthermore, do you know if Spotware has plans to fix this issue? Could someone from Spotware please comment here?
Thanks and best regards, Stefan
Hi there,
This is not supported at the moment and will not be supported in the future as historical data regarding market hours are not available.
Best regards,
Panagiotis
@PanagiotisCharalampous
stefan1
30 Dec 2024, 11:19
RE: RE: RE: Symbol.MarketHours not working in backtest
PanagiotisCharalampous said:
stefan1 said:
algobeginner said:
How about use your own historical data to emulate this factor ?
Hello and thanks for your reply. Unfortunately I don't have data other than those provided by the Ctrader charts. In case I manage to get other data, could you please explain what you mean by “emulate this factor”? Furthermore, do you know if Spotware has plans to fix this issue? Could someone from Spotware please comment here?
Thanks and best regards, Stefan
Hi there,
This is not supported at the moment and will not be supported in the future as historical data regarding market hours are not available.
Best regards,
Panagiotis
Hello Panagiotis,
Thanks for your reply. I now understand that the problem is within the historical data. But what is the workaround then? Obviously everyone wants to make a reliable backtest, before running the Cbot on a live account. Are there any code examples how to solve this?
Thanks and best regards, Stefan
@stefan1
PanagiotisCharalampous
03 Jan 2025, 08:12
( Updated at: 03 Jan 2025, 08:13 )
RE: RE: RE: RE: Symbol.MarketHours not working in backtest
stefan1 said:
PanagiotisCharalampous said:
stefan1 said:
algobeginner said:
How about use your own historical data to emulate this factor ?
Hello and thanks for your reply. Unfortunately I don't have data other than those provided by the Ctrader charts. In case I manage to get other data, could you please explain what you mean by “emulate this factor”? Furthermore, do you know if Spotware has plans to fix this issue? Could someone from Spotware please comment here?
Thanks and best regards, Stefan
Hi there,
This is not supported at the moment and will not be supported in the future as historical data regarding market hours are not available.
Best regards,
Panagiotis
Hello Panagiotis,
Thanks for your reply. I now understand that the problem is within the historical data. But what is the workaround then? Obviously everyone wants to make a reliable backtest, before running the Cbot on a live account. Are there any code examples how to solve this?
Thanks and best regards, Stefan
If you do not have the historical information, then there is no reliable workaround. You can only assume that the past market hours were the same to the current ones.
Best regards,
Panagiotis,
@PanagiotisCharalampous
algobeginner
24 Dec 2024, 16:17
How about use your own historical data to emulate this factor ?
@algobeginner