Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Trades don't always execute

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

    Market Trades don't always execute

    In my strategy script, I am using two instruments. I usually enter and exit both instruments on the same tick. In fact, the Enter calls are on adjacent lines in the code, and the Exit calls are on adjacent lines in the code.

    What I am finding, though, is that one of the Exit calls (occassionally) doesn't appear to submit an order, and thus never gets executed to close the position.

    For example, on one tick, we execute this code:
    if ( doTrade )
    {
    EnterLong( 0, 10, "Long Primary" );
    EnterShort( 1, 10, "Short Secondary" );
    }

    on a subsequent tick, we execute this code:

    if ( exitTrade )
    {
    ExitLong( 0, 10, "Exit Primary", "Long Primary" );
    ExitShort( 0, 10, "Exit Secondary", "Short Secondary" );
    }

    on subsequent ticks, I check the Positions[0 and 1] to make sure I've gone flat. But, one or the other the Exits will still be a full position (not even partially closed) after well more than 10 1-minute bars have gone by.

    Is there a race condition or other problem that may occur when submitting orders on two instruments literally back-to-back? What can I do to guarantee that both orders are submitted and confirmed as received before continuing my strategy?

    Thanks!

    #2
    That is because you are submitting both Exit() orders to the same barsInProgress index instead of to the two separate instruments.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Ooops! My bad on the original post. I double-checked the code just now, and it uses the correct indices. The post should have read:

      f ( exitTrade )
      {
      ExitLong( 0, 10, "Exit Primary", "Long Primary" );
      ExitShort( 1, 10, "Exit Secondary", "Short Secondary" );
      }

      So, my question still stands.

      Also, I running now with the simulator (earlier today was with paper trading on live quotes), and I am getting the same results. It appears to be the second Exit that never fills. And, again, it goes okay on the first round trip, but the second round trip is where it fails.
      Last edited by malbeth35; 09-24-2008, 03:56 PM.

      Comment


        #4
        You will need to debug as per these tips then: http://www.ninjatrader-support.com/v...ead.php?t=3627
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Excellent! Thanks, Josh, that did the trick.

          I was using the wrong trade name in one of my exit conditions, so it was unable to match up the entrySignalName I was passing into the Exit... call with the actual entrySignalName.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          578 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X