Automatic change stop loss in trailing stop loss

Created at 03 Mar 2021, 11: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!

Automatic change stop loss in trailing stop loss
03 Mar 2021, 11:10


Wouldn't it be great to have the option to activate a function in cTrader platform to change the normal SL in TSL after the price has moved a certain amount of pips?

Example: if my SL is at 20pips and my TP is at 200 pips, I would like the platform to change my SL in TSL after I'm in 60 pips profit without me having to manually do that.

I think this a great idea, hope you can consider it, after all you already have the advanced stop loss which moves the SL to breakeven after a certain amount of pips in profit, I think it would be fairly easy for you to code this. 

 


cTrader
@sergiualexandrugrigore19932018
Replies

amusleh
04 Mar 2021, 11:01

RE:

sergiualexandrugrigore19932018 said:

Wouldn't it be great to have the option to activate a function in cTrader platform to change the normal SL in TSL after the price has moved a certain amount of pips?

Example: if my SL is at 20pips and my TP is at 200 pips, I would like the platform to change my SL in TSL after I'm in 60 pips profit without me having to manually do that.

I think this a great idea, hope you can consider it, after all you already have the advanced stop loss which moves the SL to breakeven after a certain amount of pips in profit, I think it would be fairly easy for you to code this. 

 

You can use a cBot, use this sample cBot:

using cAlgo.API;
using System;

namespace cAlgo.Robots
{
    /// <summary>
    /// Changes current symbol positions normal stop loss to trailing stop loss once it reached x amount of pips in profit
    /// </summary>
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class StopLossToTSL : Robot
    {
        [Parameter("Pips Profit", DefaultValue = 20)]
        public double PipsProfit { get; set; }

        protected override void OnTick()
        {
            foreach (var position in Positions)
            {
                if (!position.SymbolName.Equals(SymbolName, StringComparison.OrdinalIgnoreCase)
                    || position.HasTrailingStop
                    || !position.StopLoss.HasValue
                    || position.Pips < PipsProfit) continue;

                ModifyPosition(position, position.StopLoss, position.TakeProfit, true, position.StopLossTriggerMethod);
            }
        }
    }
}

 


@amusleh