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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        574 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X