Daily profit

Created at 23 Jan 2024, 19:01
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!
AndreaPereira's avatar

AndreaPereira

Joined 02.12.2023

Daily profit
23 Jan 2024, 19:01


Hi Forum, Which method should I use to get daily profit? Thank you every all.


@AndreaPereira
Replies

firemyst
24 Jan 2024, 02:11

//Get the historical trade stuff.
HistoricalTrade ht = History.FindLast(yourposition.Label, yourposition.SymbolName, yourposition.TradeType);

 


@firemyst

AndreaPereira
24 Jan 2024, 14:17

RE: Daily profit

Hey, thanks for the help, I'll try to implement what you wrote, then I'll tell you if it works.

firemyst said: 

//Get the historical trade stuff.
HistoricalTrade ht = History.FindLast(yourposition.Label, yourposition.SymbolName, yourposition.TradeType);

 

 


@AndreaPereira

ChrisSpire
03 Feb 2024, 15:04

RE: Daily profit

firemyst said: 

//Get the historical trade stuff.
HistoricalTrade ht = History.FindLast(yourposition.Label, yourposition.SymbolName, yourposition.TradeType);

If you are looking for a daily profit from all your closed trades, you can try:

var DailyProfit = History.Where(x => x.ClosingTime.Date == Server.Time.Date).Sum(x => x.NetProfit);

if you want to filer just the current symbol (where you run cBot):

var DailyProfit = History.Where(x => x.ClosingTime.Date == Server.Time.Date).Where(x => x.Symbol == Symbol).Sum(x => x.NetProfit);

if you want to sum open positions profit try (for all symbols):

var OpenPositionsProfit = Positions.Sum(x => x.NetProfit);

@ChrisSpire

AndreaPereira
04 Feb 2024, 15:49 ( Updated at: 04 Feb 2024, 16:27 )

Daily profit

Thanks a lot Lanikeha, I will try the code soon and let you know. Good day.

Update: It works.

Lanikeha said: 

firemyst said: 

//Get the historical trade stuff.
HistoricalTrade ht = History.FindLast(yourposition.Label, yourposition.SymbolName, yourposition.TradeType)

 


@AndreaPereira