Mix OnTick and OnBar in Robot
Mix OnTick and OnBar in Robot
17 Dec 2018, 10:36
If I use an OnTick handler and an OnBar handler in a cBot I get the following message.warning:
you are going to backtest 'xxxx' using h2 (open prices) data mode 'xxxx' cBot handles OnTickEvent while h2 (open proces) data mode is designed for cBots with OnBar handler only.
Can anyone tell me what the problem with using these eventhandlers in 1 cBot is?
My strategy has to check ontick and onbar both.
Replies
Shares4UsDevelopment
18 Dec 2018, 10:44
Hi Panagiotis,
Yep I understood that.
I think the qeustion is better put this way:
The Question is: Why is there a problem with using these 2 eventhandlers in 1 cBot . e.g. What can go wrong?
Best rgds,
Ton
@Shares4UsDevelopment
... Deleted by UFO ...
PanagiotisCharalampous
18 Dec 2018, 11:12
Hi Ton,
There is no problem in using them both in a cBot. The problem is using OnTick() and backetesting with data that will not trigger OnTick() properly. If you use OnTick() in your cBot but backtest using h2 (open prices) then you will be getting the same Symbol.Bid and Symbol.Ask price for every tick until the bar changes. This will result to wrong backtesting result.
Best Regards,
Panagiotis
@PanagiotisCharalampous
Shares4UsDevelopment
18 Dec 2018, 12:37
Hi Panagiotis,
Thanks that was the answer i was waiting for (not hoping though)
So it's safe to use live but on backtest the tickdata is wrong.
So i'd better use tick and simulate h2 in Backtesting myself I guess.
Any chance this flaw in Tickdata will be repaired anytime soon?
Best rgds,
Ton
@Shares4UsDevelopment
PanagiotisCharalampous
18 Dec 2018, 12:53
Hi Ton,
I am not sure what do you mean with "flaw" and "simulate h2 in Backtesting". There is no flaw here and nothing to simulate. If you use tick data in backtesting then you will get an accurate backtest result no matter if you are using OnTick(), OnBar() or both. If you use h2 (open prices) you will not get an accurate backtesting result in case you are using OnTick(). It only uses bar open prices and it is suitable for cBots using only OnBar(). But it saves time in data downloading backtesting execution and optimization.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
17 Dec 2018, 11:48
Hi Ton,
The problem is with your backtesting data, not with the event hanlders. If you want to backtest a cBot with logic in OnTick(), then you should be using tick data and not h2 (open prices).
Best Regards,
Panagiotis
@PanagiotisCharalampous