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 Orion815, 05-02-2024, 08:39 AM
          3 responses
          19 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by frenkmly, Today, 04:49 AM
          0 responses
          5 views
          0 likes
          Last Post frenkmly  
          Started by ETFVoyageur, Yesterday, 07:05 PM
          2 responses
          19 views
          0 likes
          Last Post bltdavid  
          Started by MGHORBEL, 05-06-2024, 06:41 AM
          4 responses
          23 views
          0 likes
          Last Post MGHORBEL  
          Started by ChastiJose, Today, 03:37 AM
          0 responses
          7 views
          0 likes
          Last Post ChastiJose  
          Working...
          X