Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Send multiple orders at the same time

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

    Send multiple orders at the same time

    Hello guys,

    I like to send a multiple orders at the same time but I can send only one (the first one), the next ordes are "null value".

    //protected override void OnStateChange()
    //{
    // if (this.State == State.SetDefault)
    // this.DefaultQuantity = 1;
    // this.EntriesPerDirection = 1;
    // this.EntryHandling = EntryHandling.UniqueEntries;
    // And more ......

    //protected override void OnOrderFromMyLibrary(sbyte s)
    //{
    // double price = this.Close[0];
    //
    // if (-1 == s)
    // this.Sell_Out = this.EnterLongStopMarket(quantity: this.DefaultQuantity, stopPrice: this.price + (this.TickSize * 15)); <---- It's OK
    //
    // this.Sell_Lmt = this.EnterShortLimit(quantity: this.DefaultQuantity, limitPrice: this.price + (this.TickSize * 5)); <---- It returns a null value
    //
    // this.Buy_Lmt = this.EnterLongLimit(quantity: this.DefaultQuantity, limitPrice: this.price - (this.TickSize * 25)); <---- It returns a null value
    //
    // else
    //
    // this.Sell_Lmt = this.EnterShortLimit(quantity: this.DefaultQuantity, limitPrice: this.price + (this.TickSize * 25)); <--- It's OK
    //
    // this.Buy_Lmt = this.EnterLongLimit(quantity: this.DefaultQuantity, limitPrice: this.price - (this.TickSize * 5)); <---- It returns a null value
    //
    ​​​​​​​// this.Buy_Out = this.EnterShortStopMarket(quantity: this.DefaultQuantity, stopPrice: this.price - (this.TickSize * 15)); <---- It returns a null value
    //

    #2
    Hello JET_IN,

    Thank you for your post.

    It would be best practice to assign your order objects in OnOrderUpdate() to ensure the assignment occurs when expected. This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting.

    However, that's not the full issue here - you're running into some internal order handling rules because you're using limit and stop orders rather than market orders.

    Here's a link to our help guide that goes over the internal order handling rules with a bit more detail:


    Methods that generate orders to enter a position will be ignored if the strategy position is flat and an order submitted by an enter method is active and the order is used to open a position in the opposite direction. That's exactly what is occurring here - your EnterLongStopMarket gets submitted, then the EnterShortLimit gets rejected since the EnterLongStopMarket already got submitted in the other direction. I'm guessing you also have your Entries Per Direction setting set to 1, so your second EnterLongLimit also gets ignored because you already have one entry in that direction.

    You could consider using a market order that submits when the price reaches the level you're setting the EnterShortLimit at - what exactly is the behavior you are looking for with these orders?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate,

      I was reading the documentation and I already have the solution. The key is Unmanaged Approach: https://ninjatrader.com/support/help...antedPositions

      Thank you for your nice support!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
      7 responses
      27 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by iceman2018, Today, 11:46 AM
      0 responses
      3 views
      0 likes
      Last Post iceman2018  
      Started by akuntysh, 05-18-2018, 03:39 AM
      11 responses
      810 views
      0 likes
      Last Post Leeroy_Jenkins  
      Started by AaronKoRn, 04-27-2024, 09:49 PM
      2 responses
      26 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Creamers, 04-27-2024, 05:32 AM
      5 responses
      39 views
      0 likes
      Last Post Creamers  
      Working...
      X