Trailing stop loss and Break even function

Created at 08 Aug 2013, 13:26
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!
FO

forexner12

Joined 06.04.2013

Trailing stop loss and Break even function
08 Aug 2013, 13:26


It is very convenient if Trailing stop loss and Break even function can be put in when u create the order.


@forexner12
Replies

cAlgo_Fanatic
08 Aug 2013, 17:54

This will be considered for future implementation.


@cAlgo_Fanatic

kricka
24 Oct 2013, 18:32

Hi,

a default setting with both break-even and trailing in cTrader "Quick Execution Settings" is what we need. To be able to have both at the same time selected too, is crucial.


@kricka

Hyperloop
01 Nov 2013, 22:23

You can always make a cBot to do this. :)

private void SetTrailingStop(int argPositionID, int argTrailingStopPips, int argMinimumProfitPips)
        {
            foreach (var position in Account.Positions)
            {
                if (position.Id == argPositionID)
                {
                    if (position.Pips >= argMinimumProfitPips)
                    {
                        if (position.TradeType == TradeType.Buy)
                        {
                            Symbol XXXYYY = MarketData.GetSymbol(position.SymbolCode);
                            double NewStoploss = XXXYYY.Bid - (argTrailingStopPips * XXXYYY.PipSize);

                            if (position.StopLoss == null || NewStoploss > position.StopLoss)
                            {
                                Trade.ModifyPosition(position, NewStoploss, position.TakeProfit);
                                return;
                            }
                        }
                        else if (position.TradeType == TradeType.Sell)
                        {
                            Symbol YYYXXX = MarketData.GetSymbol(position.SymbolCode);
                            double NewStoploss = YYYXXX.Ask + (argTrailingStopPips * YYYXXX.PipSize);

                            if (position.StopLoss == null || NewStoploss < position.StopLoss)
                            {
                                Trade.ModifyPosition(position, NewStoploss, position.TakeProfit);
                                return;
                            }
                        }
                    }
                }
            }
        }

        private void SetBreakevenStop(int argPositionID, int argMinimumProfitPips)
        {
            foreach (var position in Account.Positions)
            {
                if (position.Id == argPositionID)
                {
                    if (position.Pips >= argMinimumProfitPips)
                    {
                        if (position.TradeType == TradeType.Buy)
                        {
                            if (position.StopLoss == null || position.StopLoss < position.EntryPrice)
                            {
                                Trade.ModifyPosition(position, position.EntryPrice, position.TakeProfit);
                                return;
                            }
                        }
                        else if (position.TradeType == TradeType.Sell)
                        {
                            if (position.StopLoss == null || position.StopLoss > position.EntryPrice)
                            {
                                Trade.ModifyPosition(position, position.EntryPrice, position.TakeProfit);
                                return;
                            }
                        }
                    }
                }
            }
        }

 


@Hyperloop

kricka
01 Nov 2013, 23:55

Thanks Hyperloop for posting the code. However a lot of traders are not into coding and just want the basic default of stop loss, break even, trailing and target.

It's convenient too if you mix manual trading through cTrader and robot trading with cAlgo. Spotware is aware of this of course, that a default setting is needed and I think it will be implemented in the near future. 


@kricka