Automatic closing of all transactions at once when a certain profit is achieved.

Created at 18 Feb 2025, 17:12
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!
EL

electroexport.m

Joined 18.02.2025

Automatic closing of all transactions at once when a certain profit is achieved.
18 Feb 2025, 17:12


The terminal has such functions - Take Profit or Stop Loss - but they can only be done for a single trade.

Why not make such an option in the terminal so that all trades are closed automatically when there is a total profit (profit) for all trades. For example, I make many different trades, and when the total profit or loss for all trades reaches the amount selected (in advance) by me, they are all closed at once. Why not do this!? After all, it is very convenient. And I do not need to constantly sit at the monitor, watch, and then manually close. Moreover, I may not have time to close manually when needed.
Because I did not find such an option. If it is somewhere, indicate where.


cTrader Automate
@electroexport.m
Replies

firemyst
06 Mar 2025, 05:13

Just write your own code to do it.

Sample code:

if (whatever condition is met) {
foreach (Position p in Positions)
{
    ClosePositionAsync(p, (TradeResult r) =>
    {
        if (r.IsSuccessful)
        {
            Print("Closed position \"{0} {1}\".", p.Id, p.Label);
        }
        else if (!r.IsSuccessful)
        {
            Print("WARNING! Could not close position \"{0} {1}\"!", p.Id, p.Label);
            Print("Error message: {0}", r.Error.Value.ToString());
        }
    });
}
}

@firemyst