Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Paul H.NinjaTrader Customer Service

    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
        Paul H.NinjaTrader Customer Service

        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.
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by nandhumca, Today, 03:41 PM
          0 responses
          4 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          6 responses
          33 views
          0 likes
          Last Post ScottWalsh  
          Started by frankthearm, Today, 09:08 AM
          10 responses
          36 views
          0 likes
          Last Post frankthearm  
          Working...
          X