Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamically Modifying SetStopLoss()

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

    Dynamically Modifying SetStopLoss()

    I am attempting to dynamically adjust the SetStopLoss() in the OnBarUpdate method (after initially setting it in the Initialize() method) by using the CalculationMode.Price approach and am getting some inconsistance results hence the following clarifying questions:
    1. If I place a SetStopLoss() in the Initialize() method, does that preclude me from dynamically modifying it later in the OnBarUpdate() method?
      -
    2. If I use a signal name when I place an entry order do I need to use a fromEntrySignal in my SetStopLoss() statement even if I want it to apply to any open position?
      -
    3. In the case of a long position that has made significant profit, is it possible to modify the SetStopLoss() price to be above the Position.AvgPrice yet below the current Close[0]?
      -
    4. When resetting the stop loss level on a reversing trade, does it matter in what order the SetStopLoss() is listed in relation to a reversing entry (or exit and entry) methods to properly reset the built-in stop loss for the new entry?
      -
    5. Looks like the orders generated by the built-in function abide by the same Day/GTC rules that are set for the strategy. Please confirm.
      -
    6. Are there any circumstances by which SetStopLoss() levels, once modified from their original values, would no longer allow any additional modifications, fail to generate orders, or submit orders that would not remain active until modified again? I understand SetStopLoss() methods require only one call unlike entry() and exit() methods that must be renewed with each new bar.
      -
    7. When using the TraceOrder option, should I expect to see an entry in the output window for each time SetStopLoss() is called including the stop price listed?


    Perhaps answers to these questions would be useful in the help facility. Thanks.

    Regards,

    Whitmark
    whitmark
    NinjaTrader Ecosystem Vendor - Whitmark Development

    #2
    1. No it does not.

    2. Yes.

    3. Yes. Just call SetStopLoss() and use CalculationMode.Price and set the price you want to set it to.

    4. This could be a problem since on Reverse, the stop/target are submitted at the last known price set by the SetStopLoss(). You really need to go from long, to flat, reset the SetStopLoss() then go short. This is not a problem if you always leave the SetStopLoss() with a offset amount. Passing absolute prices would be a problem on a reverse.

    5. Correct.

    6. No circumstances that NT controls.

    7. I believe so.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray,

      I suspect the issues I have having are due to entering with a specific EnterLong("LongWhenFlat") and EnterLong("LongWhenShort") type of signal names to differentiate between reversing and non-reversing entries but then using SetStopLoss("", CalculationMode.Price, NewStopPrice, false) and thinking it would address all orders. I need to confirm this.

      Even though I am using SignalNames in my entries, are you recommending the use of a generic SetStopLoss("", CalculationMode.Ticks, myDefaultStopLossTicks, false) to reset the the stop loss amount for new entries (regardless of SignalName to be used for the next trade) or must I be specific in this case too? Please confirm.

      Also, since I am using the "CalculationMode.Ticks" method to reset the stop, can I only reset it when I am Flat or can I reset it at the time when I am long and want to reverse short (for example) without impacting the open long position? As you know, stop and reverse approaches that need to reset stops without going Flat OnBarClose is a pretty common use case.

      Thanks for your clarifying responses on this topic. I must reiterate the ability in Ninja to have dynamic built-in stop loss, trailing stop, and profit target methods available to a OnBarClose strategy is a very nice feature. Thanks.

      Regards,

      Whitmark
      whitmark
      NinjaTrader Ecosystem Vendor - Whitmark Development

      Comment


        #4
        Thanks Ray,

        Even though I am using SignalNames in my entries, are you recommending the use of a generic SetStopLoss("", CalculationMode.Ticks, myDefaultStopLossTicks, false) to reset the the stop loss amount for new entries (regardless of SignalName to be used for the next trade) or must I be specific in this case too? Please confirm.
        Yes, you must be specific.

        Also, since I am using the "CalculationMode.Ticks" method to reset the stop, can I only reset it when I am Flat or can I reset it at the time when I am long and want to reverse short (for example) without impacting the open long position? As you know, stop and reverse approaches that need to reset stops without going Flat OnBarClose is a pretty common use case.
        Yes, you can only reset if flat otherwise, you will end up changing the price of a working stop/target order.
        RayNinjaTrader Customer Service

        Comment


          #5
          Hi, I've got a relevant need, I'd like to programmatically tighten my stop orders. E.g. after having called a SetStopLoss( name, CalculationMode.Price, p0, false ) I need to change the original price p0 to another value p1. Is this possible in NinjaScript?

          Comment


            #6
            check this out

            whitmark
            NinjaTrader Ecosystem Vendor - Whitmark Development

            Comment


              #7
              Thanks Whitmark!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              647 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
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X