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

MarketPosition for multiple positions

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

    MarketPosition for multiple positions

    Hi.
    How should I differentiate with MarketPosition, while I have multiple orders? i.e. I have the logic:


    if (MP != Long ) {
    if(condition)
    GO Long

    }


    however, if I have open 1 long and 1 short position, MP becomes useless. What are solutions?

    is there any method like:

    getPositionForOrder( string OrderTag)

    so i could determine positions for my orders easily then.

    #2
    Hello TazoTodua,

    All orders placed to the same instrument and same account are going to be in the same position. A position is made of all of the orders placed to that instrument and account.

    Each strategy will have its own position / positions for each instrument added to the strategy.

    This means if you place an order at 100.00 and an order at 110.00, the Position.AveragePrice will be 105.00 as this is the average entry of the two orders.

    If you place 3 separate buy orders with a quantity of 1 each the position will become long 3. If you place 1 sell order after that, the position becomes long 2.

    There will not be multiple positions if you are placing multiple orders to the same instrument and same account and changing the one position.

    To find separate positions by instrument use Positions[BarsInProgress index].MarketPosition.

    Below is public link to the help guide.


    As well as a link to a script called DailyLossLimitMultiTradeExample_NT8 that demonstrates placing multiple orders to a single position.
    Hello, I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8. These are often requested and I felt they are good examples to have for NT8. DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241 (http://ninjatrader
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      No Chelsea, I mean opposite direction trading.

      For example, I am long entry trade with "tag1" and also I have short entry trade open with "tag2". What happens in this case.

      should I use different IOrder objects to track each individual position?

      Comment


        #4
        Hello TazoTodua,

        IOrder objects cannot track a position, these are only able to hold order objects.

        Also, IOrder objects are used in NinjaTrader 7 and are not used in NinjaTrader 8.

        If you place a buy order and then a short order, your position would be flat.

        (Actually if you were long and called EnterShort(), this would flip the position from long to short)

        If you place 2 buys orders then the position would be long 2.

        If both orders (either buy or sell orders) are placed to the same instrument and same account then there will not be multiple positions. There will only be one position. You will not be able to separate the positions because there is only one position for strategy on that instrument and on that account.

        Are you trying to place these to different accounts?

        Are you asking how to save multiple Order objects to Order variables?
        Last edited by NinjaTrader_ChelseaB; 04-11-2018, 09:54 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea thank you , but I am surprised a bit.
          So I cant place multiple, separate orders (opposite)?

          Well, I did that successfully with FXCM trade and OANDA in the past.
          For example, I have long position. I dont exit that, just open another short position (without existing first), then I have two open trades.

          Is not that doable in NT with strategies? O_o ?

          Comment


            #6
            Hello TazoTodua,

            You absolutely can place orders in opposite direction.

            However, I may not be understanding your inquiry.

            I am resonding to your inquiry:
            "should I use different IOrder objects to track each individual position?"

            Placing orders in opposite directions will not result in multiple positions if they are placed to the same instrument and account. Both orders would affect the same single position.

            A trade is not the same thing as a position.

            A trade contributes to a position.

            You can have multiple trades going, but if these are placed to the same account and instrument both trades will be to the same position.

            Are you asking about separating the positions?
            If so, you need separate accounts.

            Try opening the SuperDOM and manually place a buy market order and then place a sell market order.
            What is the position after both orders are filled?

            Try placing a buy limit order 10 ticks below the ask and a sell limit order 10 ticks above the bid.
            Notice both orders are working.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              No, that's what confuses me.
              In FXCM/OANDA softares (on charts),
              I could SELL (ie. 100 contracts), while I already had i.e. 50 contract bought...

              so, on chart, I had 2 open positions:
              1 loosing and 1 winning.

              So, the SELL didnt exit the long entry, instead it opened a new trade.

              that's what i want to achieve with NT.

              I.e. I want to create SELL entry, while I still have Long order (and I dont want to exit that with SELL), instead I want to have two open positions.

              Comment


                #8
                Hello TazoTodua,

                NinjaTrader works the way a broker works. If you call your broker and place a buy order with a quantity of 1 and then place a sell order with a quantity of 1 your position will be flat.

                If you want to be long and short on the same instrument, you would have to use two accounts.

                Once account would have a long position on that instrument, the other would have a short position on that instrument.

                The same would be true with any broker you would call on the phone.

                This means that you would need to send orders to two different accounts to be long and short at the same time.

                As strategies use only one account, it would be necessary to use two strategies, one that goes long one one account, one that goes short on the other account.

                Or you place orders to two different accounts using the Addon approach and using different accounts when placing the orders.

                Below is a public link to a example script that demonstrates placing orders with the addon approach.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by gnocchi, Today, 11:56 AM
                1 response
                2 views
                0 likes
                Last Post NinjaTrader_Zachary  
                Started by FAQtrader, Today, 12:00 PM
                0 responses
                3 views
                0 likes
                Last Post FAQtrader  
                Started by geddyisodin, Today, 05:20 AM
                5 responses
                32 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by bmartz, Today, 09:30 AM
                2 responses
                13 views
                0 likes
                Last Post bltdavid  
                Started by f.saeidi, Today, 11:02 AM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X