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

Split order

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

    Split order

    I would like to split an enter long order on 10 contracts into 10 enter long order on 1 contracts. Is there an easy way to do that in strategies?
    Many thanks

    #2
    Hello paul.cabot,

    So I can best answer your question, would you be able to provide more information?

    Instead of submitting a buy order for 10 contracts you wish to submit 10 orders for 1 contract each when your buy condition becomes true?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      yes, exactly, I want to submit 10 orders for 1 contract each when your buy condition becomes true
      This is to break the 10 contracts order into 10 smaller orders
      Thanks

      Comment


        #4
        Hello paul.cabot,

        To do this I sent EnteryHandling to Unique Entries and uniquely named 10 different EnterLong calls.

        Please see EntryHandling section of our helpguide and import the attached sample.


        Please let us know if you need further assistance.
        .
        To Import a NinjaScript into NinjaTrader 8 do the following:
        From the Control Center window select Tools -> Import-> NinjaScript...
        Find the file location.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          If the total order size x is variable from day to day and the chunks are to be random numbers between 1 and 4 lots what method (loop?) is best to get that done and what order object is best employed?
          Regards and many thanks

          Comment


            #6
            Yes, use a loop. The 'order object' is no different than before.

            To submit an order with a random quantity Y between 1 and 4 until X contracts
            have been submitted, you first need a way to get a random number,
            Code:
            private static Random MyRand = new Random(DateTime.Now.Millisecond);
            then makeup a function, something like,
            Code:
            private void EnterOrder(int Direction, int totalQuantity)
            {
                int orderNum = 1;
                while (totalQuantity > 0)
                {
                    int quantity = Math.Min(MyRand.Next(1, 4), totalQuantity);
                    if (Direction > 0)
                        EnterLong(quantity, "L"+orderNum);
                    else if (Direction < 0)
                        EnterShort(quantity, "S"+orderNum);
                    totalQuantity = totalQuantity - quantity;
                    ++orderNum;
                }
            }
            which works well with these 'direction' integer constants,
            Code:
            private const int SHORT = -1;
            private const int NONE = 0;
            private const int LONG = 1;
            then, to enter random orders for a 10 contract position, call it like this,
            Code:
            EnterOrder(LONG, 10);
            Make sense?

            Comment


              #7
              Yes thx that gives me something to work from. Very much appreciated. Thank you

              Comment


                #8
                Is this applicable to UnManaged order methods with SubmitOrderUnmanaged? How is the order object defined in such a case as above to be able to create the Stop Loss and Change order stages? Regards and many thanks
                Last edited by elliot5; 05-11-2021, 08:31 AM.

                Comment


                  #9
                  Hello elliot5,

                  The above information was specifically for the Managed approach and does not specify any targets. In this specific case the Signal Name of each entry could be used for the targets because that is how the managed appraoch associates Entries with Targets.

                  For unmanaged you would instead submit the targets yourself. There is a sample of an unmanaged strategy which submits targets as OCO in the following link, that would be the suggested approach at unmanaged targets. https://ninjatrader.com/support/foru...elp#post770579

                  Please let me know if I may be of additional assistance.
                  JesseNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by jclose, Today, 09:37 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post jclose
                  by jclose
                   
                  Started by WeyldFalcon, 08-07-2020, 06:13 AM
                  10 responses
                  1,414 views
                  0 likes
                  Last Post Traderontheroad  
                  Started by firefoxforum12, Today, 08:53 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post firefoxforum12  
                  Started by stafe, Today, 08:34 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post stafe
                  by stafe
                   
                  Started by sastrades, 01-31-2024, 10:19 PM
                  11 responses
                  169 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X