Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Builder - How to Set Multiple Stop Losses for Short/Long positions

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

    Strategy Builder - How to Set Multiple Stop Losses for Short/Long positions

    Hello.

    I am trying to set multiple levels of stop losses in Strategy Builder.

    The logic would be as follows:

    if ( Close[0] >= Position.AveragePrice + L1TriggerTicksFromEntry * TickSize )
    // Set stop loss using L1StopLossInTicks
    if ( Close[0] >= Position.AveragePrice + L2TriggerTicksFromEntry * TickSize )
    // Set stop loss using L1StopLossInTicks
    if ( Close[0] >= Position.AveragePrice + L3TriggerTicksFromEntry * TickSize )
    // Set TRAIL stop using TrailStopTicks

    I know this can be done using hard coding, but I would like to accomplish this using Strategy Builder.

    Also, I would like to accomplish the opposite for a Short position. However, in Strategy Builder, when I try to change the condition to Close[0] <= Position.AveragePrice - L1TriggerTicksFromEntry * TickSize, the "-" is not available when changing "Arithmetic" to "Ticks" on the offset, so it always offsets by ADDING the ticks to the price.

    Thank you for any/all assistance.

    #2
    Hello shawnynicole,

    Thanks for your post and welcome to the NinjaTrader Forums!

    The strategy builder does not permit the use of a dynamic SetStopLoss. The SetStopLoss, in the strategy builder, is set within State.Configure and as such it cannot be set to work with dynamic (changing) variables. An alternative would be to instead place, for example when long, a SellStop order below the current price.

    If you wanted to use the SetStopLoss() method as you described, then it could only be done in a coded Ninjascript strategy.

    You cannot use the SetStopLoss() and the SetTrailStop() on the same order in the strategy builder or in Ninjascript code. If coded that way, the trail stop is simply ignored. Please see the notes in both:



    You are correct regarding the ability to negate a user-defined variable and I will check into that to see if that is something we should change. I will update this thread when i have further information. In the meantime, you can create additional variables that are set to a negative number of ticks (for your short side entries). When you add a negative number it is the same as subtraction.

    Comment


      #3
      Thank you for your reply.

      Can you please clarify for me which function I would use to accomplish placing a SellStop order for the long position? If the function to use is different for code vs Strategy Builder, can you please specify both?

      Thank you.

      Comment


        #4
        Hello shawnynicole,

        Thanks for your reply.

        In the action section of the strategy builder you would select "exit long position by a stop order" or "exit long position by a stop limit order".
        Please see, "How to exit a market position" here: https://ninjatrader.com/support/help...s/?actions.htm

        In Ninjascript, these would be:

        ExitLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm
        ExitLongStopLimit(): https://ninjatrader.com/support/help...gstoplimit.htm

        Comment


          #5
          Hello shawnynicole,

          Just to follow-up.

          Regarding, "...(strategy builder) the ability to negate a user-defined variable...".

          After an internal review, it was determined that this should be a feature request. I have submitted a feature request on your behalf. The request is assigned as SFT-3039, "User defined variables to be negated to accomplish subtraction".

          The feature request does not mean that it will or will not be implemented but will be routinely reviewed and tracked by program management.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          86 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          29 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          67 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X