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

Dynamically change the stop loss price in SetStopLoss()

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

    Dynamically change the stop loss price in SetStopLoss()

    Hi guys.
    In my strategy, I try to use SetStopLoss() with a CalculationMode.Price value inside OnBarUpdate(). And I ran into the problem of triggering a SetStopLoss() at a previous non-current price. There is a warning in the manual: https://ninjatrader.com/support/helpGuides/nt8/en-us/setstoploss.htm (Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position). This is just my case. But I do not know how to overload use SetStopLoss() in order not to use the price from the previous position. Thank.


    #2
    Hello Kostiantyn,

    Thank you for the post.

    I noted that this question was also sent into our platform support email and we have replied by email. If you have other separate questions please feel free to create another email to support or forum post. Please be sure to only use one support method at a time for the same question going forward.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      This is the logic of order execution and support. Strategy for NT8.
      Attached Files

      Comment


        #4
        Error


        Comment


          #5
          Hello Kostiantyn,

          The error states the price being used is not valid or is 0. To address this you would need to debug the script further to find why an invalid price is being used. I could suggest using Prints with the price you are using where it is being used for SetStopLoss.

          As we are already speaking through email, I would suggest replying to my prior email with these details if this is related to the script we have already been discussing so we can keep all of the information about your question in one place. If this is unrelated to your earlier post/email, please ensure to make a new thread for new questions.




          Please let me know if I may be of additional assistance.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by frslvr, 04-11-2024, 07:26 AM
          8 responses
          111 views
          1 like
          Last Post NinjaTrader_BrandonH  
          Started by stafe, 04-15-2024, 08:34 PM
          10 responses
          44 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by rocketman7, Today, 09:41 AM
          3 responses
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by traderqz, Today, 09:44 AM
          2 responses
          5 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by rocketman7, Today, 02:12 AM
          7 responses
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X