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

Multiple Positions in Same Instrument

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

    Multiple Positions in Same Instrument

    Hello,

    Could someone please explain how NT handles multiple positions in the same instrument?

    Assume I get long 5 contracts in the June YM futures contract at 10am.

    1. It is now 10:30 and I get long another 5 contracts in CL. I am now long 10 contracts.

    2. It is now 10:30 and I get short 5 contracts. My position is flat.

    In Case 1, does NT know of 2 different position objects? Or just 1 object with Quantity = 10?

    Similarly, how would NT handle Case 2?

    Thank you.

    Isaac

    #2
    Hello Isaac,

    Thanks for your reply.

    I am unclear to you inquiry.
    In your example you say you go 5 long on the YM and 5 long on the CL. These are different instruments. If you were then to exit one or both positions NinjaTrader would see these as seperate.

    If you were to scale into a position your orders will function first in first out (FIFO). Within the Account Performance these will be seen as separate trades unless the order was scaled in with an ATM strategy and you have Group Trades By ATM Strategy selected in the Account Performance tab.
    BrandonNinjaTrader Customer Service

    Comment


      #3
      Brandon,

      Apologies for the confusion. The instrument should be YM in both cases. No CL is traded.

      Assume I get long 5 contracts in the June YM futures contract at 10am.

      1. It is now 10:30 and I get long another 5 contracts in YM. I am now long 10 contracts.

      2. It is now 10:30 and I get short 5 contracts. My position is flat.

      Comment


        #4
        Hello ivb73077,

        Thanks for your reply.

        In your example NinjaTrader will properly display you as 5 long still as you have purchased 10 but only sold 5.
        NinjaTrader would process this one long trade from 10am - 10:30am
        Then one you close your second order it would be considered another trade from 10:30am - X
        BrandonNinjaTrader Customer Service

        Comment


          #5
          I don't think I have explained myself properly.

          These are two distinct scenarios and I want to understand how NT handles each:

          1. Get long 5 contracts of YM at 10am, At 10:30am, buy 5 more YM contracts. Does NT recognize 1 position of long 10? Or 2 different positions of long 5 each?

          I ask because I want to understand if I can manage the positions separately as each will have its own take-profit, stop-loss and trailing stops. I am using Unmanaged Orders and want to know if I can apply different targets for each 5-lot, or if I need to use the average position price of the combined 10-lot.

          Thanks.

          Comment


            #6
            Hello ivb73077,

            Thanks for your clarification. I follow your inquiry.

            Yes, you can code your strategy to have separate entry points with separate targets/stops. These will however function still on FIFO.

            So for example 1 you would enter in at 10am with 5 contracts and you would place your desired target and stop. At 10:30am you would scale in with an additional 5 contracts with your desired targets and stops. Now whatever exit order is filled first, this will exit you from your 1st position, even if the target/stop was made for the second position.

            In example 2 you would enter into the market at 10m with 5 contacts and you would place your desired target and stop. At 10:30am if you were filled by your target or stop then you would be flat and you would need to cancel out the other order.
            If you mean in example 2 that you want to go long and short at the same time you will technically be flat in the market however you can still have your desired targets and stops working for what would be a long position and what would be a short position. You would be shown as flat within NinjaTrader however and no PnL information would be shown for either 'position'.
            BrandonNinjaTrader Customer Service

            Comment


              #7
              Thank you.

              If I wanted to managed the 2 long orders as 2 distinct positions with different targets and stops, how would I be able to differentiate them. For example, Position.AvgPrice would presumably give me the average price for the entire 10-lot and not for the 2 5-lots.

              Further, I cannot use BarsArray[] or similar array classes to differentiate the 2 positions because the instrument is the same for both. My question centers around how to set the targets/stops and calculate the unrealized PNL for the 2 distinct positions and what event allows me to differentiate them. As a reminder, I am using Unmanaged orders.

              Comment


                #8
                Originally posted by ivb73077 View Post
                Thank you.

                If I wanted to managed the 2 long orders as 2 distinct positions with different targets and stops, how would I be able to differentiate them. For example, Position.AvgPrice would presumably give me the average price for the entire 10-lot and not for the 2 5-lots.

                Further, I cannot use BarsArray[] or similar array classes to differentiate the 2 positions because the instrument is the same for both. My question centers around how to set the targets/stops and calculate the unrealized PNL for the 2 distinct positions and what event allows me to differentiate them. As a reminder, I am using Unmanaged orders.
                Use the IOrder.AvgFillPrice for each order.

                Comment


                  #9
                  Very useful suggestion. Thank you.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Taddypole, 04-26-2024, 02:47 PM
                  2 responses
                  12 views
                  0 likes
                  Last Post Taddypole  
                  Started by futtrader, 04-21-2024, 01:50 AM
                  6 responses
                  58 views
                  0 likes
                  Last Post futtrader  
                  Started by sgordet, Today, 11:48 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post sgordet
                  by sgordet
                   
                  Started by Trader146, Today, 11:41 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post Trader146  
                  Started by jpapa, 04-23-2024, 07:22 AM
                  2 responses
                  22 views
                  0 likes
                  Last Post rene69851  
                  Working...
                  X