Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entering multiple IOrders

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

    Entering multiple IOrders

    Could someone explain how I could enter multiple IOrders? The trick is, I don't want to do them one by one, but instead have it done in a loop.

    The following example is not complete. I'd like to change the IOrder name "MySellOrder" to be "MySellOrder_1", "MySellOrder_2", etc, etc. - depending on the index.


    Code:
    double priceFromAsk = GetCurrentAsk();
    
    for (int index = 1; index <= 20; index++) 
    {
          MySellOrder  = SubmitOrder(0,OrderAction.SellShort,OrderType.Limit,1,priceFromAsk,0,"","shortAtAsk_" + index);
         priceFromAsk = priceFromAsk + .01;
    }

    Thanks!

    #2
    Hi Flack,

    Thank you for your post and welcome to the forums.

    This would not be possible since NinjaScript requires that each IOrder have the variable declared before submitting orders.

    You can have it set for the Signal names that you currently have set in the sample code.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      You can have it set for the Signal names that you currently have set in the sample code.
      I'm not following this sentence. Could you elaborate?

      Thank you

      Comment


        #4
        Flack,

        I was referring to the SubmitOrder() code that you provided.

        SubmitOrder(0,OrderAction.SellShort,OrderType.Limi t,1,priceFromAsk,0,"","shortAtAsk_" + index);

        The bolded part is the signal name of the order.

        With each loop the index value would increase by 1 to the signal name.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Okay. I see.

          I guess my whole problem is. At times I need to cancel all open orders. Can I cancel an order by the Signal Name? I didn't think that was possible. If so, I could simply loop through them and cancel. If not, do you have a suggestion how I can cancel all of the orders?




          Originally posted by NinjaTrader_Cal View Post
          Flack,

          I was referring to the SubmitOrder() code that you provided.

          SubmitOrder(0,OrderAction.SellShort,OrderType.Limi t,1,priceFromAsk,0,"","shortAtAsk_" + index);

          The bolded part is the signal name of the order.

          With each loop the index value would increase by 1 to the signal name.

          Comment


            #6
            Flack,

            CancelOrder() requires that you use the IOrder name in order to cancel the order.

            You would need to have a CancelOrder() for each open order that you have placed.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Cal View Post
              Flack,

              CancelOrder() requires that you use the IOrder name in order to cancel the order.

              You would need to have a CancelOrder() for each open order that you have placed.
              It sounds like there is no way in NT to create several limit orders via a loop and expect to be able to cancel them. That is unfortunate.

              Thanks anyway.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              649 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              370 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              576 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X