No announcement yet.

Partner 728x90


StopLoss & TrailingStop doesn´t work together

  • Filter
  • Time
  • Show
Clear All
new posts

    StopLoss & TrailingStop doesn´t work together

    I tried to put a StopLoss and a TrailingStop in my strategy. Unfortunately they do not work together in backtest, just the StopLoss is working if I use both. It looks like StopLoss overwrites TrailingStop. If I use just one of them it is working.
    What could be the reason to ignore TrailingStop?
    Last edited by Jesse; 03-29-2009, 07:09 PM.

    Hi Jesse, thanks for your post, this is expected as SetStopLoss and SetTrailStop can't be used together working on the same position (signal name). You can use the ideas presented in this reference sample to code your trailing stop by modifying the SetStopLoss value -
    BertrandNinjaTrader Customer Service


      I'm also running into this SetStopLoss + SetTrailStop problem (again).

      I noticed this shortcoming of NinjaTrader two years ago when I first started coding NinjaScript, and decided to code around the problem by implementing my own trailing stops.

      It's doable, but this is a lot of unnecessary work for anyone who wants both to set a stop loss and then at a later time run with a trailing stop.

      This same funcionality is nicely accomplished by using the ATM Strategies and SuperDOM or chart trader functions in NinjaTrader, but there is no way to supply an ATM strategy on-the-fly, based on program generated requirements. For this and other limiting factors, once again I've given up on programatically accessing the ATM strategy components. So I'm back to implementing my own Auto Breakeven and Trailing Stop code.

      So, how about providing a way to simply cancel an existing SetStopLoss value? This would allow programmers to switch from SetStopLoss to SetTrailStop. And if implemented it would be nice if NinjaTrader would then use the most recent SetTrailStop value specified (then we wouldn't be running 'naked' with no stop loss set, if even for a short period of time.)

      As an implementation suggestion, perhaps just setting a stop loss price of zero could be used as an indication that the programmer wants to cancel the current stop loss?

      This would then allow programmers to be able to easily do their own breakeven strategies (which requires a SetStopLoss) and then later switch to a SetTrailStop, without a lot of extra, unneeded complexity.

      Thanks for listening (or should we say reading.)


        KBJ, thank you for your detailed input and suggestions.
        BertrandNinjaTrader Customer Service



          I am also interested to cancel a stoploss and switch to trailingstoploss. Has there anything been implemented in the last 1.5 years?
          In some other posts you suggest to set the stoplimit far away, but this does not help in this case, because NT ignores trailingstops if a stoploss exists. Also your reference example which resets the stoploss does not help, because we are looking for a trailing stop loss. In some posts you mention that a stop loss could be canceld by orderid?
          I would appreciate if you could give a code example how a stoploss is cancelled and a new trailingstop setup.


            Beauregard, Bertrand's advice in post #2 still stands: "You can use the ideas presented in this reference sample to code your trailing stop by modifying the SetStopLoss value -".

            Another option would be to use IOrders, but that would still require you to move the stop with code instead of it being done automatically.

            There have been many discussions on the forum for how to code trailing stops, please take a look at the results generated by this search. Unfortunately it is not possible to share searches on the forum, but you can click search and then type in "trail stop" or "trailing stop" or something similar and get many results.
            AustinNinjaTrader Customer Service


            Latest Posts


            Topics Statistics Last Post
            Started by Nolyn, Today, 10:59 AM
            0 responses
            1 view
            Last Post Nolyn
            by Nolyn
            Started by Gkomi, Today, 10:02 AM
            1 response
            Last Post NinjaTrader_Jim  
            Started by JTizz, Today, 08:58 AM
            6 responses
            Last Post NinjaTrader_PaulH  
            Started by Bob49, Today, 08:40 AM
            0 responses
            Last Post Bob49
            by Bob49
            Started by Malik_demoacct, Today, 08:31 AM
            0 responses
            Last Post Malik_demoacct