Simple query regarding OnTick() functionality in backtesting
Simple query regarding OnTick() functionality in backtesting
11 Sep 2014, 06:27
Hi Team and Fellow members,
Can you please clarify how OnTick() works in backtesting as i am trying to get all the ticks ie..Symbol.Bid for a 1 day duration in my bot to do some analysis but it is returning me data points which are 15 milliseconds away each time inside OnTick(). Example output
08/20/2014 00:00:15 1.66202
08/20/2014 00:00:30 1.66194
08/20/2014 00:00:45 1.66202
I was assuming that i should be able to see ticks coming at any time and not evenly placed with 15 milliseconds away. Can someone please help or explain ? I need to see the history of ticks .
Replies
Spotware
11 Sep 2014, 10:02
( Updated at: 21 Dec 2023, 09:20 )
Currently m1 data mode provides 4 ticks for every m1 bar (open, high, low, close). In cAlgo 1.25 we are going to change this behavior: m1 data mode will provide only 1 tick for every bar (open price).
If your strategy requires more ticks we can recommend you to use tick data mode instead of minute bars:
@Spotware
trend_meanreversion
11 Sep 2014, 10:37
( Updated at: 21 Dec 2023, 09:20 )
i tried that one but now it is saying 'Cannot load tick data'. How can i access tick data then in history ?
@trend_meanreversion
trend_meanreversion
11 Sep 2014, 11:10
( Updated at: 21 Dec 2023, 09:20 )
i downloaded Spotware cAlgo and tried 'Tick data from Server(accurate)' but got different error this time . I have sent you troubleshooting logs ( Shift+Ctrl+Alt+T ).
My bot is just trying to print/dump tick data ( Bid/Ask ). Please help !!
@trend_meanreversion
trend_meanreversion
12 Sep 2014, 00:33
I sent probably 10 times to you guys. Besides not having access to TickData , i have seen one more problem today
1) My bot is simply dumping bid/ask which is coming in live env ( not in backtesting ) using Print() with using timeFrame of 1 min . I have put my print() statement in OnTick() function and there is no OnBar() function . In this case, i am not able to see bot doing anything and not printing anything on screen even though i can see ticks moving.
Why is OnTick() function not getting triggered ? I am so confused at this stage . Please help.
@trend_meanreversion
Spotware
12 Sep 2014, 09:54
I sent probably 10 times to you guys.
We haven't received troubleshooting information yet. Please make sure that your antivirus and firewall software do not block troubleshooting information.
1) My bot is simply dumping bid/ask which is coming in live env ( not in backtesting ) using Print() with using timeFrame of 1 min . I have put my print() statement in OnTick() function and there is no OnBar() function . In this case, i am not able to see bot doing anything and not printing anything on screen even though i can see ticks moving.
Why is OnTick() function not getting triggered ? I am so confused at this stage . Please help.
Please make sure that your previous OnTick handler finished. In order to do that you can add a print statement to the begging of OnTick handler and one more print statement to the end.
Example:
protected override void OnTick() { Print("OnTick started"); //your code here Print("OnTick finished"); }
@Spotware
trend_meanreversion
12 Sep 2014, 12:10
RE:
Spotware said:
I sent probably 10 times to you guys.
We haven't received troubleshooting information yet. Please make sure that your antivirus and firewall software do not block troubleshooting information.
1) My bot is simply dumping bid/ask which is coming in live env ( not in backtesting ) using Print() with using timeFrame of 1 min . I have put my print() statement in OnTick() function and there is no OnBar() function . In this case, i am not able to see bot doing anything and not printing anything on screen even though i can see ticks moving.
Why is OnTick() function not getting triggered ? I am so confused at this stage . Please help.
Please make sure that your previous OnTick handler finished. In order to do that you can add a print statement to the begging of OnTick handler and one more print statement to the end.
Example:
protected override void OnTick() { Print("OnTick started"); //your code here Print("OnTick finished"); }
Thanks Team. It is fixed now.
But now in new version, i see that we don't have Open/High/Low/Close for historical bars. Is it possible at all to retrieve that information in bot ? I tried all mode of backtesting ( tick data, 1m(open) , 1hr(open) etc ) and in all modes OnBar() gives me a single price for open/high/low/close. What is a bot depends on historical High - Low etc..
Appreciate your help.
@trend_meanreversion
Spotware
12 Sep 2014, 14:59
OnBar method is invoked when new bar is opened. At that moment MarketSeries collection already contains tick from new bar. It means that last bar is not formed and in general cases open = high = low = close. If you want to access to last formed bar you need take previous one.
You can use following code to access to the previous bar:
Print("Open: {0}, High: {1}, Low: {2}, Close: {3}", MarketSeries.Open.Last(1), MarketSeries.High.Last(1), MarketSeries.Low.Last(1), MarketSeries.Close.Last(1));
@Spotware
trend_meanreversion
13 Sep 2014, 10:50
RE:
Spotware said:
OnBar method is invoked when new bar is opened. At that moment MarketSeries collection already contains tick from new bar. It means that last bar is not formed and in general cases open = high = low = close. If you want to access to last formed bar you need take previous one.
You can use following code to access to the previous bar:
Print("Open: {0}, High: {1}, Low: {2}, Close: {3}", MarketSeries.Open.Last(1), MarketSeries.High.Last(1), MarketSeries.Low.Last(1), MarketSeries.Close.Last(1));
Thanks a lot guys ! Cheers
@trend_meanreversion
trend_meanreversion
11 Sep 2014, 06:44
RE:
Sorry i mean 15 seconds ( not milliseconds)..i am getting only 4 quotes per 1 min duration inside OnTick() in backtesting, while there should be way more than that as TickVolume is much higher.
Spotware team, can you please advise ?
trend_meanreversion said:
@trend_meanreversion