Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy historical closes at random price. NT bug or mine?

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

    #16
    Hello DarkWehler,

    If you are using Calculate.OnBarClose, only intrabar granularity is necessary. Make sure the orders are actually being submitted to the 1-tick series, this sample script demonstrates:



    If you are still seeing unexpected behavior in historical after properly implementing intrabar granularity you'll need to debug the script using prints and TraceOrders.

    Comment


      #17
      Originally posted by NinjaTrader_Gaby View Post
      If you are still seeing unexpected behavior in historical after properly implementing intrabar granularity you'll need to debug the script using prints and TraceOrders.
      I was having a number of issues (on historical) with my move-to-breakeven code. I finally decided that it must be something to do with order handling being in it's own thread. So I moved the breakeven code from BIP=1 (ticks) to OnExecutionUpdate(), when I see that the first target has been hit. That seems to have fixed many of them, but I still see anomalies like this, where it's moved to BE - 3 (I have it set to move to breakeven + 1):

      ​​​Click image for larger version  Name:	image.png Views:	0 Size:	9.1 KB ID:	1320573

      I have a lot of logging in the program, and from the log, I have

      ​#000 - NQ 12-24 - [OnExecutionUpdate] - 03-Oct-24 20:10:00 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Name = TP1, IsEntryStrategy = False, OrderAction = Sell, marketPosition = Short, quantity = 1, Position.Quantity = 1, price = 20032.5
      m = 1, Ave Price = 20025.5, set new SL to be 20025.75

      So here, OnExecutionUpdate is called when TP1 closes half the position. It's a long market position, but it's reporting Short/Sell because it's TP1, which is a Sell Limit. It checks the TP1 name, and correctly calculates the price where to move the stoploss.


      #000 - NQ 12-24 - [ModifyStopLoss] - 03-Oct-24 20:10:00 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Moving SL for 1 contract(s) to new price @ 20025.75 (BreakEven)

      My ModifyStopLoss method is setting it to this correct price.


      #000 - NQ 12-24 - [OnOrderUpdate] - 03-Oct-24 20:10:00 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      order.Name = SL2; Setting slOrder2, price = 20025.75

      OnOrderUpdate gets the notification that is has been set to the correct price.


      #000 - NQ 12-24 - [OnExecutionUpdate] - 03-Oct-24 20:16:00 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Name = SL2, IsEntryStrategy = False, OrderAction = Sell, marketPosition = Short, quantity = 1, Position.Quantity = 0, price = 20024.75
      Position.Quantity == 0; cancelling stops

      But then, when OnExecutionUpdate is called, it has the price off by $1.

      Is this a NT bug? I cannot see any reason why it would change between OnOrderUpdate and OnExecutionUpdate.




      Last edited by DerkWehler; 10-05-2024, 09:36 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      48 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      66 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X