Close All trades when total profit is > x

Created at 02 Jun 2014, 10:10
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!
DA

davidp13

Joined 06.05.2014

Close All trades when total profit is > x
02 Jun 2014, 10:10


Hi,

Im running a system that has max 5 trades open. Im looking for a command or robot that will close all trades when combined profit or loss for that matter reaches a certain point.

Can anyone help me pls?

Thanks once again!


@davidp13
Replies

davidp13
02 Jun 2014, 21:39

Guess this can work...

public class CloseProfitablePositions : Robot
    {
        protected override void OnTick()
        {
            if (Account.Equity - Account.Balance > 250)
            {
                foreach (var position in Account.Positions)
                {
                    Trade.Close(position);
                }
            }

            //Close on negative
            if (Account.Equity - Account.Balance < -100)
            {
                foreach (var position in Account.Positions)
                {
                    Trade.Close(position);
                }
            }
        }
    }


@davidp13