Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How works SetTrailStop()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How works SetTrailStop()

    Hi, im trying to do an automatic trailing stop in my strategy with this example, but there was errors and conflicts when i move the SetStopLoss().


    I am reading about SetTrailStop() function in this help document:


    but dont works in my strategy.

    How exactly works the SetTrailStop() function?
    There are some specific example?

    Thank tou very much.

    #2
    Hello marynja,

    SetTrailStop() will only work if there is not also SetStopLoss() defined.

    It places a stop order at the last traded price +/- the specified tick or percent. Mode price does not make sense in trail stop context.

    Example:
    Long Position enters at 1000
    Trail stop defined at 10 ticks is placed initially at 990.
    If market raises to 1010, stop loss is moved to 1000.

    Adjustments to the price are made either on every tick or on bar close depending on CalculateOnBarClose setting. It will not retreat in other direction - in example above, it stays at 1000 if trading goes from 1010 to 1000.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much RyanM
      There was a SetStopLoss() defined into my code.
      Now works ok.

      i ask me if could i define separately the stoploss and the trial amount. its possible?
      Could i asign an ATM strategy saved in my NT to my strategy code?

      Thanks again.

      Comment


        #4
        If you want to combine SetStopLoss() and SetTrailStop() in the same strategy, then they must apply to separate entries signals through the fromEntrySignal parameter. If they apply to the same entries, then stop loss is always used.

        Yes, you can connect NinjaScript strategy to an ATM strategy. There is sample available in the platform. Click Tools > Edit NinjaScript > Strategy > SampleAtmStrategy

        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        59 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        283 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X