Close maximum profitable trade.
Created at 11 Sep 2021, 09:38
AN
Close maximum profitable trade.
11 Sep 2021, 09:38
I opened 5 trade positions. I want to close a maximum profitable position. And the rest of the positions will remain open. How can I do that?
Replies
amusleh
13 Sep 2021, 11:06
Hi,
You can use the position NetProfit property and check which one has the maximum profit, once you found it then you can close it, to get the most profitable position you can use this linq query:
var mostProfitablePosition = Positions.OrderBy(position => position.NetProfit).LastOrDefault();
if (mostProfitablePosition != null)
{
ClosePosition(mostProfitablePosition);
}
@amusleh
... Deleted by UFO ...