Todays Net Profit

Created at 17 Sep 2018, 19:59
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!
IF

iForex2015

Joined 17.03.2015

Todays Net Profit
17 Sep 2018, 19:59


Hi,

I wrote code for showing some info on chart and I want to show todays total net profit. Can anybody help ?


@iForex2015
Replies

PanagiotisCharalampous
18 Sep 2018, 09:20

Hi,

What kind of help do you need? Calculating today's net profit?

Best Regards,

Panagiotis


@PanagiotisCharalampous

iForex2015
18 Sep 2018, 18:16

Hi ,

Yes, I need help to calculate todays profit. For example I have this code for history net profit 

  var history = History.Where(t => t.SymbolCode == Symbol.Code);
  var historyProfit = (int)(history.Sum(t => t.NetProfit));

 and I want to show net profit  between a particular time (system time) something like this ?

 var profitToday = History.Where(t => t.SymbolCode == Symbol.Code && t.ClosedDate.Date == DateTime.Now.Date).Sum(t => t.NetProfit);

 

Thanks


@iForex2015

PanagiotisCharalampous
19 Sep 2018, 10:43

Hi,

You can try something like this

var profitToday = History.Where(t => t.SymbolCode == Symbol.Code && t.ClosingTime.Year == DateTime.Now.Year &&  t.ClosingTime.DayOfYear == DateTime.Now.DayOfYear).Sum(t => t.NetProfit);

Best Regards,

Panagiotis


@PanagiotisCharalampous

iForex2015
20 Sep 2018, 06:22

Hi 

It worked. Perfect . Thank you. 


@iForex2015