Close maximum profitable trade.

Created at 11 Sep 2021, 09:38
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!
AN

anikaurmi420

Joined 18.10.2020

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?


@anikaurmi420
Replies

... Deleted by UFO ...

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