Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scaling Into a Position

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

    Scaling Into a Position

    Hi - I was wondering what is the best way to scale into position, gradually with 1 contract entry at a time? I was experimenting with some code that does an entry of 1 contract, does Sleep for 2 seconds, and tries another entry of 1 contract. I got an error that says "There already is a matching order with the same price and quantity". The main goal is spread multiple orders throughout the minute series. Any ideas?

    #2
    Hello,

    You can find an example of scaling into a position in the following link. To scale into a position you would use multiple signal names so that you can also scale out of that position if you wanted. Scaling takes multiple entries. https://ninjatrader.com/support/help...a_position.htm

    The error you are seeing is based on the broker being used and the quantity/price used for the order. If the order values are identical you would have to wait longer than a few seconds before submitting a new order or use limit orders to ensure different prices are used for the orders.

    Comment


      #3
      So if each order had a unique name, the order would have gone through?

      Comment


        #4
        Hello szayedoud,

        No, the error states the price and quantity was identical, you need to use a different price for the next order.

        Comment


          #5
          Why does the price have to be the same for the next order? I just want the market price. I can't imagine it's the same price on fast moving market like ES and NQ, after waiting 2 seconds. I tired 20 market orders, with a 2 second pause in between (in a loop). Currently, I did this in a script that is Calculate.OnBarClose. I will try it Calculate.OnPriceChange and see I process 20 orders that way - does this like a good workaround?

          Comment


            #6
            Hello szayedoud,

            I believe you have misunderstood the error, you need a different price for the next order not the same price. The broker wont allow an identical order to be submitted. The next order needs to have a new price.

            You can use market orders but you need more time between the orders if 2 seconds is allowing the same price for the order. That or you can use limit orders where you specify a unique price per order.

            Comment


              #7
              Limit orders are not guaranteed to be filled, I need market orders. I waited 3 seconds in between 10 contracts of NQ, and 2 seconds in between 20 contracts of ES and all attempts after the first order got the same error. Prices change rapidly within 2-3 seconds in these markets. If the error ( and what you're saying) is correct, the price never changed in the 30-40 second time period, since none of the orders went through after the first entry. Do you understand how this doesn't make sense?

              Comment


                #8
                Hello szayedoud,

                The only way to guarantee a new price is used would be to wait a longer period of time when you can observe a new price or to use a limit type order where you specify a price. You can create logic to look and see if a new price is present or use one of the more granular calculation modes like OnEachTick or OnPriceChange. The error you are seeing is coming specifically from the broker letting you know that the order you submitted was not valid based on the price and quantity matching an existing order.

                Comment


                  #9
                  Ok, I will try OnPriceChange and see if I can scale out the orders that way. Thansk.

                  Comment


                    #10
                    So in my attempt to try scaling in/out on a more granular level, I set my Strategy to Calculate.OnPriceChange. I set PrintStatements to see how often OnBarUpdate gets called. My data series is 1 minute. My expectations is that it would get called several times a minute since the price of ES 12-22 is constantly changing. Would you agree that this would be the expected behavior?

                    However, the print statements time stamps are 9:01, 9:02, 9:03, 9:16, 9:17.

                    (1) It's not being called several times a minute, its not even being called once a minute!
                    (2) It did not even get called from 9:03 to 9:16.

                    Any ideas?

                    Comment


                      #11
                      Never mind! Even though the OnPriceChange was set in the Script, for some reason its always defaulting to OnBarClose in the Strategy Parameters and I missed that. Other parameters do reflect what is set in the Script, but no this one - maybe for cautionary reasons

                      Comment


                        #12
                        Hello szayedoud,

                        That can happen if you had modified the default and then did not re apply the strategy, any item in State.SetDefaults requires that you remove and re add the strategy. That can also happen if you saved a default preset for the strategy.

                        Comment


                          #13
                          Thanks for the feedback

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Today, 05:17 AM
                          0 responses
                          52 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          130 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          70 views
                          0 likes
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          44 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Started by TheRealMorford, 03-05-2026, 06:15 PM
                          0 responses
                          49 views
                          0 likes
                          Last Post TheRealMorford  
                          Working...
                          X