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

Keep needing to exit ...

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

    Keep needing to exit ...

    Hello,

    I have set profit target and stop loss. I enter using EnterLongLimit and ShortLimit.

    Due to calculations, I need to exit before PT or SL is hit.

    Do I use ExitLong / ExitShort? But I was advised not to mix them with profit target and stop loss.

    How should I be doing this?

    Many Thanks, Caesar.

    #2
    Hello Caesar,

    It is not advised to mix Set methods with order methods like ExitLong() orders.

    If you are using ExitLongStopMarket() as the stop loss, call CancelOrder() with the order object assigned from OnOrderUpdate(), detect the order is cancelled in OnOrderUpdate(), and then send the exit market order. This will ensure that both orders are not able to fill causing an unwanted position.
    https://ninjatrader.com/support/help...ancelorder.htm
    https://ninjatrader.com/support/help...rderupdate.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      So, detect the target order (add a "myLimitOrder" string to the target order has been filled in OnOrderUpdate, and then CancelOrder(myStopMar****rder)?

      But you advise against mixing Set PT/SL with Exit orders.

      So, what is the proper way to do what I want?

      Many Thanks, Caesar.

      Comment


        #4
        Hello Caesar,

        Right, SetStopLoss() would not be used. ExitLongStopMarket() would be used instead for the stop loss. So this way the set methods are not used and are not mixed with exit methods.

        Yes, you can give your exit orders names and detect this in OnOrderUpdate().

        ExitLongLimit(100.00, "myLimitOrder", "myEntry");

        In OnOrderUpdate():
        if (order.Name == "myLimitOrder")
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ah clarity, finally, Huge Thanks Chelsea!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,227 views
          0 likes
          Last Post xiinteractive  
          Started by andrewtrades, Today, 04:57 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          7 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          440 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          12 views
          0 likes
          Last Post FAQtrader  
          Working...
          X