Loading historical tick data

Created at 27 Jul 2020, 17:13
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!
SA

sascha.dawe

Joined 11.02.2019

Loading historical tick data
27 Jul 2020, 17:13


Hi, 

The below sample shows loading historical bars. 

Is it possible to show a code sample loading historical tick data on an indicator?

 

Thanks,

Sascha

 

Note, in the previous versions tick data was accessible only if cBot or indicator was running on Tick1 chart and only for bid prices using old MarketSeries. With the new API you can access tick data from any timeframe and use bid and ask prices

Load more history

For both Bars and Ticks you can load more history using LoadMoreHistory or LoadMoreHistoryAsync methods.
Below Is an example of loading 10 000 bars on the chart

Print("{0} bar on the chart. Loading 10 000 bars", Bars.Count);
while (Bars.Count < 10000)
{
    var loadedCount = Bars.LoadMoreHistory();
    Print("Loaded {0} bars", loadedCount);
    if (loadedCount == 0)
        break;
}
Print("Finished, total bars {0}", Bars.Count);

Output:
1143 bar on the chart. Loading 10 000 bars
Loaded 1141 bars
Loaded 1162 bars
Loaded 1129 bars
Loaded 1090 bars
Loaded 1126 bars
Loaded 1134 bars
Loaded 1134 bars
Loaded 1166 bars
Finished, total bars 10225


@sascha.dawe
Replies

PanagiotisCharalampous
31 Jul 2020, 08:01

Hi Sascha,

There is no function to load historical data in the API. 

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous