Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order mismatch between historical and live trades

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

    Order mismatch between historical and live trades

    I have been programming in NT C# and running live strategies for years now. I don't believe I have seen this before, but I get different contract counts when I am live (and market replay) vs historical data. My only guess is that I must have introduced a bug in one of my strategies, but I can't find it, even in the debugger.

    I have watched exactly what is does in the debugger and it looks correct. Today I was trading YG 06-13 with 60 min bars. I had a long position tagged as "L1" and I then do an ExitLong("EL1", "L1"); and then an EnterShort(DefaultQuantity, "S1"); I checked in the debugger and DefaultQuantity is set to 1.

    When I do a market replay I see on the chart, "EL1 1 at 1568.3" then, "Close position 1 at 1568.3", then "S1 1 at 1568.3"! When I was running live today it did just this, it actually had 2 positions on at once (2 short), even though the strategy is set to "Set order quantity: default quantity" and "Default quantity: 1". Looking at what shows up on the chart it is probable it is a problem with closing out the long position, because there is only one "S1" listed, one "EL1" and then this strange "Close position 1".

    So I checked the documentation and from that I expect "L1" to be my long entry "signal". "EL1" is my exit of long signal, from entry signal "L1". Then my new short entry is entry signal "S1". Here is that TraceOrders:

    4/8/2013 11:30:02 AM Entered internal PlaceOrder() method at 4/8/2013 11:30:02 AM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='EL1' FromEntrySignal='L1'
    4/8/2013 11:30:02 AM Entered internal PlaceOrder() method at 4/8/2013 11:30:02 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='S1' FromEntrySignal=''

    #2
    I made a code update to make sure everything was explicit and it still does the same thing. I made sure both entries and exits had the quantity variable:
    ExitLong(DefaultQuantity, "EL1", "L1");
    EnterShort(DefaultQuantity, "S1");

    Here is the updated TraceOrders output, going back to include the entry on 4/5/2013 as well:
    4/5/2013 10:30:00 AM Entered internal PlaceOrder() method at 4/5/2013 10:30:00 AM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='ES1' FromEntrySignal='S1'
    4/5/2013 10:30:00 AM Entered internal PlaceOrder() method at 4/5/2013 10:30:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='L1' FromEntrySignal=''
    4/8/2013 11:30:02 AM Entered internal PlaceOrder() method at 4/8/2013 11:30:02 AM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='EL1' FromEntrySignal='L1'
    4/8/2013 11:30:02 AM Entered internal PlaceOrder() method at 4/8/2013 11:30:02 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='S1' FromEntrySignal=''

    So how does this TraceOrders output result in 2 positions?
    Last edited by tradetree; 04-08-2013, 07:30 PM.

    Comment


      #3
      tradetree, so when you want to reverse your position you call then ExitLong followed by the EnterShort? This would be actually a duplicate call since the Enter methods would reverse automatically for you, so the separate ExitLong is not needed here.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Why doesn't the documentation note such a critical behavior? I read and re-read every description and there is no mention of this. I double checked right now and can't find it even indirectly.


        Originally posted by NinjaTrader_Bertrand View Post
        tradetree, so when you want to reverse your position you call then ExitLong followed by the EnterShort? This would be actually a duplicate call since the Enter methods would reverse automatically for you, so the separate ExitLong is not needed here.

        Comment


          #5
          Hi tradetree, it's documented in the managed approach subsection under Entry Methods - I will forward a suggestion though to have it mentioned as well for each Enter() method helpguide page explicitly.

          BertrandNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          7 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          6 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X