Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATMStrategyChangeEntryOrder() acting weird

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

    ATMStrategyChangeEntryOrder() acting weird

    I have a strategy that places a stop order and moves the stop price on each bar. For this example in Market Replay, let's say I'm putting a buy stop order on the CL instrument. The price is 94.19 up to the end of the range bar. On the first tick of the next bar, the price needs to move up to 94.30. I call the ATMStrategyChangeEntryOrder() method to change the price on the first tick of the bar. However, the order gets filled on the next tick anyway at 94.20 even through the stop price was successfully reset to 94.30.

    It seems like the method is not really resetting the stop order, even though the call to the method comes back True. Can you please help explain why this is happening?

    Here is the snip of the tracelog file of the order right before and after the stop price is changed and the order is filled at the wrong price.

    Code:
    2011-06-22 16:18:55:147 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Working Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.19 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:148 (Market Replay Connection) Cbi.Order.Change: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' State=Working Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Strategy='(null)' Type=Stop Tif=Day Oco='' Filled=0 Fill price=0 Token='721fe2e74bf94628b4c6e6d98898b086' Gtd='12/1/2099 12:00:00 AM'
    2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.OrderStatusEventArgs: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=PendingChange Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.Order.Update1: oldid='721fe2e74bf94628b4c6e6d98898b086' Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=PendingChange Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.OrderStatusEventArgs: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Accepted Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.Order.Update1: oldid='721fe2e74bf94628b4c6e6d98898b086' Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Accepted Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.OrderStatusEventArgs: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Working Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.Order.Update1: oldid='721fe2e74bf94628b4c6e6d98898b086' Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Working Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=PendingChange Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:150 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Accepted Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:151 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Working Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Simulator.Fill1: id='721fe2e74bf94628b4c6e6d98898b086' maxFillQuantity=1 price=94.2
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Simulator.Fill2: id='721fe2e74bf94628b4c6e6d98898b086' fillQuantity=1 price=94.2
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Simulator.FillNow: id='721fe2e74bf94628b4c6e6d98898b086' state='Working' instrument='CL 08-11' quantity=1 filled=0 price=94.2
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.OrderStatusEventArgs: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Filled Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=1 Fill price=94.2 Error=NoError Native error=''
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Order.Update1: oldid='721fe2e74bf94628b4c6e6d98898b086' Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Filled Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=1 Fill price=94.2 Error=NoError Native error=''
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.ExecutionUpdateEventArgs: Execution='a02f791092904446bbb424714323ab86' Instrument='CL 08-11' Account='Replay101' Exchange=Default Price=94.2 Quantity=1 Market position=Long Operation=Insert Order='721fe2e74bf94628b4c6e6d98898b086' Time='6/17/2011 10:09:47 AM'
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.ExecutionUpdateEventArgs2: executionId='a02f791092904446bbb424714323ab86' entry=True exit=False position=1 multiplier=1 rate=1 sod=False
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.PositionUpdateEventArgs1: Instrument='CL 08-11' Account='Replay101' Avg price=94.2 Quantity=1 Market position=Long Operation=Insert Currency=Unknown
    2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Filled Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=1 Fill price=94.2 Error=NoError Native error=''
    2011-06-22 16:18:55:161 (Market Replay Connection) Strategy.AtmStrategy.ManageBrac****rders0: filled=1 outstanding=0 filledOrders:721fe2e74bf94628b4c6e6d98898b086+=1  outstandingOrders:
    2011-06-22 16:18:55:161 (Market Replay Connection) Strategy.AtmStrategy.ManageBrac****rders1: bracket=0 qty=1 stopOrdersOutstandingQuantity=0 stopOrders:
    2011-06-22 16:18:55:161 (Market Replay Connection) Strategy.AtmStrategy.ManageStopOrder: idx=0 orderType=StopLimit quantity=1 limitPrice=93.91 stopPrice=94.11 oco='412beefe-84a7-41e0-aa6f-200a90c90a17'
    Thanks!
    Bryan

    #2
    Thanks for the report, Bryan. I just checked this and basic functionality seems to be working fine. A couple notes:

    The method returns true if it finds the order, but this does not mean successful in changing it.

    It looks like the last working price before your fill is 94.3.

    To debug this, you should look at the actual price of the order, not the fill price. Stop orders are submitted as market orders which does not guarantee a fill price. It's not unexpected to see it fill one tick worse than specified price.

    ChartTrader works well to visualize the order, or you can use SuperDom, or orders tab.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Thanks for the report, Bryan. I just checked this and basic functionality seems to be working fine. A couple notes:

      The method returns true if it finds the order, but this does not mean successful in changing it.

      It looks like the last working price before your fill is 94.3.

      To debug this, you should look at the actual price of the order, not the fill price. Stop orders are submitted as market orders which does not guarantee a fill price. It's not unexpected to see it fill one tick worse than specified price.

      ChartTrader works well to visualize the order, or you can use SuperDom, or orders tab.
      I have already debugged it from NY to Denver and still cannot figure out why it would have filled the order at 94.20 when the Buy Stop order was clearly moved to 94.30. What really puzzles me are these lines in the trace:

      Code:
      2011-06-22 16:18:55:149 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=PendingChange Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='' 
      2011-06-22 16:18:55:150 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Accepted Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='' 
      2011-06-22 16:18:55:151 (Market Replay Connection) Cbi.OrderStatusEventArgs.Process: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Working Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
      2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Simulator.Fill1: id='721fe2e74bf94628b4c6e6d98898b086' maxFillQuantity=1 price=94.2 
      2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Simulator.Fill2: id='721fe2e74bf94628b4c6e6d98898b086' fillQuantity=1 price=94.2 
      2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Simulator.FillNow: id='721fe2e74bf94628b4c6e6d98898b086' state='Working' instrument='CL 08-11' quantity=1 filled=0 price=94.2 
      2011-06-22 16:18:55:153 (Market Replay Connection) Cbi.Connection.ProcessEventArgs.OrderStatusEventArgs: Order='721fe2e74bf94628b4c6e6d98898b086/Replay101' Name='Entry' New state=Filled Instrument='CL 08-11' Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=1 Fill price=94.2 Error=NoError Native error=''
      And the puzzling piece is this part of the last line:

      Code:
      Action=Buy Limit price=0 Stop price=94.3 Quantity=1 Type=Stop Filled=1 Fill price=94.2
      Stop Price = 94.3, Fill Price = 94.2. How can that be? Why would you get a fill 10 ticks below the buy stop price?

      Another strange thing about this case is that the entry order status goes from Accepted to Working on the last tick of the prior bar. Then on the first tick of this bar, the stop is moved to 94.3 and the order is still Working. Then the second tick of this bar and the order becomes Filled. I think there's something wrong in the internal order placing code around the first tick of a bar. Can we investigate this further on your end? I am not sure how much more I can debug on my end.
      Last edited by cassb; 06-22-2011, 08:20 PM.

      Comment


        #4
        Sure, we can work towards finding a reproducible scenario. The basic functionality is working fine to change entry orders here. Do you feel market replay is contributing here? Do you see the same thing on a simulated data feed? Can you share a script we can use to see the same thing here? Please let us know all relevant details like the specific day and interval used for market replay, if the're your own recorded files or NT provided.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        646 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        367 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X