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

Exit order doesn´t run with SetStopLoss

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

    Exit order doesn´t run with SetStopLoss

    Hello,
    I have a simple strategy .
    In this code I put the "SetStopLoss" method inside OnBarUpdate(), just after sending an EnterLong order.
    When the profit is >= 12 ticks above the entry price, I send an ExitLongStopMarket order , but It doesn´t run ,
    because I see that the SetStopLoss() method to exit this long position always cancel the ExitLongStopMarket order.
    How can I do to use this ExitLongStopMarket order together with the protection of the SetStopLoss() method ?
    Attached Files

    #2
    Hello Parmenides48,

    It is not advised to use multiple exits for a single entry. Even if you are wanting to scale out, its necessary to have separate entries with different signal names.

    What you are doing is violating the Internal Order Handling Rules.

    "Methods that generate orders to exit a position will be ignored if:
    A position is open and an order submitted by a set method (SetStopLoss() for example) is active"

    https://ninjatrader.com/support/help...antedPositions

    If you are using ExiLongStopMarket(), just use that and don't use SetStopLoss(). These both send the same kind of order anyway.



    Also, you should always call Set methods before placing the order. This is because Set methods cannot be unset and will continue to be set for new orders. If you want to alter the set method, this should be done before the entry fills and the order is already submitted.
    Last edited by NinjaTrader_ChelseaB; 01-21-2019, 11:45 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your fast answer.
      But, how do I do to cancel the SetStopLoss to use the ExiLongStopMarket() order?
      The problem is that when the order to enter is filled, I immediately need protection till the end of that bar !.
      If I write :
      EnterLong();
      ExitLongStopMarket();

      I see that the second order to protect my new Long position ( in this entry bar ) doesn't run ( as if doesn't know my new long position) !!!,
      So, I have to put SetStopLoss() to protect my new long position.
      But in the next bars , If I decide to exit in certain price with an ExitLongStopMarket() order, I can't.

      Then, How do I do to cancel SetStopLoss() and use an ExitLongStopMarket() order ??

      Comment


        #4
        Hello Parmenides48,

        SetStopLoss() orders cannot be cancelled.

        I am suggesting that if you plan to use ExitLongStopMarket() with a specific entry order, don't use SetStopLoss() at all on that entry order.

        You can submit an order the moment the entry order fills in OnExecution() or OnOrderUpdate().

        Below is a link to an example.
        https://ninjatrader.com/support/foru...269#post802269
        Last edited by NinjaTrader_ChelseaB; 01-21-2019, 12:57 PM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks a lot for your answer. I am going to work on it.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Barry Milan, Yesterday, 10:35 PM
          4 responses
          15 views
          0 likes
          Last Post Barry Milan  
          Started by DanielSanMartin, Yesterday, 02:37 PM
          2 responses
          13 views
          0 likes
          Last Post DanielSanMartin  
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          11 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          8 views
          0 likes
          Last Post nandhumca  
          Working...
          X