Non-trailing Stop Loss

Created at 26 Aug 2016, 17:15
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!
AR

armstr.tradie

Joined 30.03.2016

Non-trailing Stop Loss
26 Aug 2016, 17:15


I am trying to find a way to create a stop-loss that moves when a trigger is reached, but does not follow the price continually.

 

I would like to set a normal stop loss that is behind the opening price at the start of my trade as one usually does, but say after 10 pips profit it creates a new stop loss at 5 pips (behind that trigger) - and stays there. 

 

Here is my code for my normal trailing bot.

        protected void TrailingStops()
        {

            var positions = Positions.FindAll(label);
            if (positions == null)
                return;

            foreach (var position in positions)
            {
                if (position.Pips >= TrailingTrigger)
                {
                    if (position.TradeType == TradeType.Buy)
                    {
                        var newStopLoss = Symbol.Bid - TrailingStop * Symbol.PipSize;
                        if (position.StopLoss < newStopLoss)
                            ModifyPosition(position, newStopLoss, position.TakeProfit);
                    }
                    else if (position.TradeType == TradeType.Sell)
                    {
                        var newStopLoss = Symbol.Ask + TrailingStop * Symbol.PipSize;
                        if (position.StopLoss > newStopLoss)
                            ModifyPosition(position, newStopLoss, position.TakeProfit);
                    }
                }
            }
        }

I'm having trouble getting my head around this as I keep getting a trailing stop or errors.

 

I thought about setting :

var newStopLoss = Symbol.Bid - TrailingStop * Symbol.PipSize;

to:

var newStopLoss =  Stoplevel * Symbol.PipSize;

 

If any one has any thoughts it would be greatly appreciated.


@armstr.tradie
Replies

... Deleted by UFO ...

armstr.tradie
27 Aug 2016, 05:50

RE:

lucian said:

Try :

 

var newStopLoss =  position.EntryPrice+/-Stoplevel * Symbol.PipSize;

 

Thanks lucian.

I'l give it ago on Sunday/Monday when the markets open and see how it goes.


@armstr.tradie