Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic managing of multiple orders

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

    Dynamic managing of multiple orders

    Hi Ninjas,

    I have a script that has 4 independent modules, each one can trigger a buy or sell order. Reading how NT manages orders, I struggle to know which is the more efficient and simple way to manage the dynamic right "balance" of position through orders. I'll explain this better with following situations:

    1. Imagine each one of the 4 modules triggers a 100K EURUSD Buy orders, in order to open and keep the position of 400K, I had to set 4 orders X 100K each, so, in order to do this, is it good enough just allowing 4 entries for that script and setting four separated EnterLong() instructions? or just allowing 1 entry but identifying each one of that orders with a different SignalName?

    2. Now imagine that the situation has changed, now I got 3 Long position Vs 1 Short position, in order to get and keep the new balance of 200K, which would the best method to do this? :

    A) just allowing 4 entries in the script and setting these orders
    EnterLong(100000);
    EnterLong(100000);
    EnterLong(100000);
    EnterShort(100000):

    B) just allowing 1 entry in the scrip but setting the orders
    EnterLong(100000, "mod 1")
    EnterLong(100000, "mod 2")
    EnterLong(100000, "mod 3")
    EnterShort(100000, "mod 4")

    Thanks

    #2
    pstrusi, both EntryHandling modes are valid but it depends if you want to tie a specific exit for example to any signal. Then the unique entry name would be helpful of course.

    Comment


      #3
      Thanks Bertrand for your response.

      Last question:

      Following with the last example, imagine that you Algo has a 200K Long position, and suddenly the script changes and trigger 3 Short position Vs 1 Long Position, would it reverse the position correctly with just setting 3 unique EnterShort(100000) and 1 EnterLong() to a 200K Short position?

      I imagine that NT has the capability to determine that now it has to achieve the new 200K Short position, but it's kind of confusing to me that just with these few orders can reverse it completely
      Last edited by pstrusi; 11-05-2013, 04:44 AM.

      Comment


        #4
        Correct, the Enter() methods in the managed mode will reverse for you if needed. So if you're 200K long and issue 3x100K Short then your new target position is 300K short. NT closes the open longs get you into the new position.

        Comment


          #5
          Bertrand, for simplicity I imagine that this can be done:

          Imagine that you Algo has a 400K Long position, and suddenly its modules changes its balance and now it has to set down to 200K Long position or even a 200K Short position; so instead of setting multiple Entries as:

          EnterLong(100000);
          EnterLong(100000);
          ......
          ......

          would it be possible to set just one entry with the quantity previously calculated in the script?, like this

          Balance: 400K Long to bring it to a 200K Short position, I'll only need to set

          EnterShort (200000); and the system nicely will manage all orders necessary to set the new balance, right?

          If so, and having in mind that balance could change in size of 100K, going from 400K Short up to 400K Long, how must I configure the EntryPerDirection and EntriesHandling ?

          Thanks

          Comment


            #6
            That would be doable as well, so you have essentially one order with changing qty that you calculate dynamically. However please note you then not be able to scale out / in. The Entry handling would then be set to AllEntries and per direction to 1, as you're just dealing with one entry here either long or short and your target qty.

            Comment


              #7
              Bertrand, could you please explain me better what do you mean by
              "please note you then not be able to scale out / in."

              I mean, for example if I had a 200K Long position and I'd like to increase it up to 400K, wouldn't it be possible to do it by changing the unique entry to EnterLong (400000) ?.
              Last edited by pstrusi; 11-05-2013, 12:37 PM.

              Comment


                #8
                Hi pstrusi,

                Thanks for your note.

                The issue comes from using the same signal name to continue entering orders.

                Below is a hypothetical situation that can occur.

                Lets say you were to enter a long position of 10 using the entry signal "entry" and trying to scale in 5 and then 5 again. You also have 2 ExitLongLimit orders with the signal names "exit1" and "exit2". Both exits use a quantity of 5. The EntriesPerDirection is set to 3.

                Lets say that after the initial order the position is 10 and exit1 is hit. The position is now 5. Then the strategy scales 5 so the position quantity is 10. When that happens you try and set another exit order with exit1. This order will be ignored. The order will continue to be ignored until the entry order is completely exited.

                In other words dynamically scaling in and out using 1 order and 1 entry signal name can prevent you from re-applying any exit orders using that entry signal.

                The best approach (using the managed approach) is to use an individual order with one stop and one target. Then you can use these in units (for example you could have each order be 100,000). Then scaling in and out would be easy and you would not have to worry about orders being ignored.

                Really, the very best way would be to use the unmanaged approach were you can completely control your position and just send orders to buy or sell whatever quantity you would like. Then you script logic would be able to manage all of that.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea, thanks for your response, very clear, although a doubt remains:

                  You tell that this problem is with limit orders only? what if I use only market orders, the same?

                  Comment


                    #10
                    Hi pstrusi,

                    Yes, same story whether a limit order or market order. The issue is with re-using signal names.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks a lot for your response and interest to make me clear this issue

                      Comment


                        #12
                        Hi Bertrand and Chelsea.

                        I've been trying to code simple procedures for scaling in/out with unmanaged orders, but it really is a difficult task cause the multiple necessary layers to count on in order to have a trust on it.

                        Reading in the help guide about details in managed orders, I've read something that obviously it could help in coding scaling in/out BUT with managed orders. I've read the following:

                        "You can close out a partial position by specifying the exit quantity, example: ExitLong(100) "

                        So an eventual Long position that you could have will be reduced using this feature. If so, it's possible to figure a way out in how creating Scaling in/Out procedures with managed orders.

                        Any ideas, suggestions or warnings about it to have in mind ?

                        Thanks

                        Comment


                          #13
                          By the way, as always, if I find out something that it could be useful, I post it here. So I've found this thread that it looks pretty simple and useful to come out with better ideas about scaling in/out with managed orders http://www.ninjatrader.com/support/f...hlight=scaling

                          Thanks for your attention, and any idea or suggestion will be highly appreciated

                          Comment


                            #14
                            Hello pstrusi,

                            As long as you are using the latest version of NinjaTrader and you are using an entry signalName and unique exit signalNames this should work ok.

                            The following code seems to work ok:
                            Code:
                            if (Historical)
                            return;
                            
                            if (Position.MarketPosition == MarketPosition.Flat)
                            {
                            EnterLong(10,"myLong");
                            }
                            else
                            {
                            ExitLong(5, "exit"+CurrentBar, "myLong");
                            }
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Chelsea, thanks for your response.

                              I saw this code, but the scaling in/out is when you have already a position (not just a flat position) and it must be adjusted to a new size. In the code of that thread that I've posted earlier, and even in the Help guide, it seems that you could use the ExitLong(size) or ExitShort(size) with no problems to reduce positions; and if you set properly the EntriesPerDirection correctly, you can add positions as well.

                              I'm trying to do a simple code using this feature, when I have time to finished I'll post it here.

                              Regards

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              65 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              41 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              23 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              26 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              52 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X