Daily Starting Account.Balance

Created at 22 Jun 2020, 19:57
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!
DelFonseca's avatar

DelFonseca

Joined 25.06.2017

Daily Starting Account.Balance
22 Jun 2020, 19:57


Hello, I need get the Account.Balance from the beginning of the day, the following code does not work, can someone help me?
It's important if the robot is disconnected after making trades, when connecting it will not be able to count the trades performed, hence the need to access the history.

HistoryDailyStartingBalance = History.Where(x => x.ClosingTime.Date.Day == Server.Time.Date.Day).OrderByDescending(x => x.EntryTime).Last().Balance;

Thank you


@DelFonseca
Replies

Jiri
23 Jun 2020, 00:33

Hi, try this: 

History.Any() ? History.Last(x => x.ClosingTime.Date < Time.Date).Balance : Account.Balance

 


@Jiri

DelFonseca
23 Jun 2020, 01:58

RE:

Jiri said:

Hi, try this: 

History.Any() ? History.Last(x => x.ClosingTime.Date < Time.Date).Balance : Account.Balance

 

 

Thank you very much for your help. Work perfectly!
Best regards


@DelFonseca