Need Help sum net profit for all closed Position
Need Help sum net profit for all closed Position
04 Nov 2021, 21:41
I tired to sum every closed Position
every time it rest the value to the last net profit
I try both " lastTrade.NetProfit" and " LastResult.Position.NetProfit"
I'm working on cBot that stop at certain Netprofit
could you help me please,
Thank you in advance
Regards;
Replies
mohsabry.ms
05 Nov 2021, 14:41
RE: Thank you for helping
amusleh said:
Hi,
You can use history to sum the net profit of all your closed positions (trades):
var netProfit = History.Sum(trade => trade.NetProfit);
To get net profit of all your open positions you can use Positions:
var netProfit = Positions.Sum(position => position.NetProfit);
It works well,
Appreciate your help
Regards,
@mohsabry.ms
mohsabry.ms
06 Nov 2021, 01:29
RE: RE: Thank you for helping
Hi,
If I wanna to choose from history some specific closed trades that i labeled it before as "sell_today"
how to modify this code to select them only;
var netProfit = History.Sum(trade => trade.NetProfit);
Forgive me I'm just a beginner
Thank you in advace
Best Regards,
@mohsabry.ms
PanagiotisCharalampous
08 Nov 2021, 08:17
Hi mohsabry.ms,
Here you go
var netProfit = History.Where(trade => trade.Label == "sell_today").Sum(trade => trade.NetProfit);
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
amusleh
05 Nov 2021, 07:35
Hi,
You can use history to sum the net profit of all your closed positions (trades):
To get net profit of all your open positions you can use Positions:
@amusleh