History do not contain values after cTrader is restarted

Created at 09 Mar 2023, 13:29
R.

r.artsiom.vinnikau

Joined 09.03.2023

History do not contain values after cTrader is restarted
09 Mar 2023, 13:29


Hello,

After restarting cTrader, History do not contain any values. But when I refresh history manually in terminal, I also can obtain refreshed values in cBot. I need to obtain history from cBot without any manipulation from terminal, can I do this? Thanks.


@r.artsiom.vinnikau
Replies

firemyst
10 Mar 2023, 07:39

Can you post example C# code which demonstrates the issue through the API?


@firemyst

r.artsiom.vinnikau
10 Mar 2023, 14:08 ( Updated at: 10 Mar 2023, 14:09 )

RE:

firemyst said:

Can you post example C# code which demonstrates the issue through the API?

Hi,

I put following code in cBot OnStart() method:

            var historyItemsCount = History.Where(x => x.ClosingTime >= DateTime.UtcNow.Date.AddDays(-20)).Count();
            Print($"historyItemsCount = {historyItemsCount}");

And then I run cBot on just started terminal and obtain following result:

10/03/2023 15:02:37.197 | historyItemsCount = 0

Then I do refresh on History tab in terminal for current month and start cBot. Then I obtain next result:

10/03/2023 15:05:55.896 | historyItemsCount = 1055

What I want to achieve - do refresh of history from code, or obtain history without refresh.


@r.artsiom.vinnikau