Is it safe to use the index of the bar while the bot is running?

Created at 21 Sep 2020, 18:20
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!
KO

koktos632

Joined 18.01.2020

Is it safe to use the index of the bar while the bot is running?
21 Sep 2020, 18:20


Hi!
It looks like the cTrader may reduce the size of timeseries available  (Bars.Count) to the bot.

The bot uses the index of the bar for some calculations.
The last used index of the bar is stored in the member variable.

I think cTrader from time to time REDUCES the size of the historical data available to the bot. It causes the last used bar is not valid now.
Last know event when the value of Bars.Count was reduced was about 21/09/2020 00:09 (GMT+0300) on GBPJPY.
The chart type was Renko4. The broker was IC Markets 
There were several another instances of the same bot on different symbols. All another symbols except GBPJPY were working as expected.

I cannot replicate it of course.


My question is
Is the number of bars Bars.Count increasing only while the bot is running? (my version of the answer is  No. The Bars.Count may decrease from time to time)   
Is it possible to get Bars.Count less than Bars.Count on the previous call of  OnBar() while the bot is running? (my version of the answer  Yes. It is possible to get the value of Bars.Count on the next call of onBar less than the previous one )

Regards

 

 


@koktos632
Replies

PanagiotisCharalampous
22 Sep 2020, 07:51

Hi koktos632,

Yes, there is a possibility that Bars.Count will change while the cBot is running e.g. due to a reconnection and a refresh of the chart.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

koktos632
22 Sep 2020, 15:14

RE:

"... due to a reconnection and a refresh of the chart."
Is it possible to set a handler for these events?


@koktos632