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 and multiples entries.

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

    Exit order and multiples entries.

    Hi,

    I have created a strategy which open positions based on two different signals (it can acumulate 2 positions at the same time).

    I am trying to close both positions using only an exit order when a specific condition is true. In order to do it I write nothing in the blank “from entry signal” of the order. However it does not work. The strategy this way closes one position on one bar and the other position on a different bar if the condition has been true.

    In order to solve that I need to create two exit orders, one for each entry signal, and I have to link each exit order to each entry signal using the “from entry signal” option.

    My question is: Is there any way of using just one exit order to close both positions at the same time?

    Thank you in advance.

    #2
    Hello Plaket,

    Thanks for opening the thread.

    If you use the overload for ExitLong() or ExitShort() that does not include a fromEntrySignal, the exit method should exit all open positions in that direction.

    In the demo below, I enter long with 2 different entries and exit my positions with a single call to ExitLong().

    Demo: https://www.screencast.com/t/i4uyntc2

    Please let me know if this information does not resolve your inquiry.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you Jim,

      Great demostration. I really appreciate the video. Thanks.

      I am creating the strategy using Strategy Builder (Not the editor). I have created a simple strategy that reproduces the issue that I am describing.

      Attach you'll find a screenshot of the code generated (by Strategy Builder) + a screenshot of the problem on a bar chart when I try to run it.

      Perhaps, it is not possible using just an order thru Strategy Builder?

      Thank you again for your great support.
      Attached Files

      Comment


        #4
        Hello Plaket,

        Thanks for that detail.

        You are currently telling ExitLong() to exit with the DefaultQuantity, so it will only exit that number of contracts when the method is called.

        If you use "Strategy \ Current position size" for the Quantity of the exit, your strategy should exit all of the contracts in your current position. This will display as Position.Quantity once added.

        Please let me know if this does not resolve your inquiry.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thank you again Jim. Everything is fixed that way.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by frslvr, 04-11-2024, 07:26 AM
          6 responses
          105 views
          1 like
          Last Post NinjaTrader_BrandonH  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          6 responses
          26 views
          0 likes
          Last Post trilliantrader  
          Started by arvidvanstaey, Yesterday, 02:19 PM
          5 responses
          14 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Started by Rapine Heihei, Yesterday, 08:25 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Mongo, Yesterday, 11:05 AM
          6 responses
          27 views
          0 likes
          Last Post Mongo
          by Mongo
           
          Working...
          X