Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OrderState is not accurate in Playback Mode

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

    OrderState is not accurate in Playback Mode

    Dear Developer Team,
    I'm coding an indicator that takes trades using the AddonApproach. To make sure I only take trades in one direction at a time I check if the entry, stoploss and targetorders in the opposite direction are null before I enter a trade (Methods NoLongTrades() and NoShortTrades()). It ran as expected in sim101 account. Now I wanted to proceed my work on the indicator and tested it in playback mode. It started taking trades in the opposite direction eventhough I was still in a trade. I added prints to the OnBarUpdate() method to check the OrderState of my different orders. And they showed up to be null eventhough they were actually working or Filled. I attached screenshots from my code, the chart, the output window and the orders tab from when I paused the playback after the faulty behaviour occured.
    The Long order should be Filled, the Target Order should be Working but their both null. Is that a playback bug or did I miss something?
    Thank you for your help!
    Click image for larger version

Name:	Screenshot 2025-02-22 235807.png
Views:	86
Size:	75.8 KB
ID:	1335541 Click image for larger version

Name:	Screenshot 2025-02-22 234235.png
Views:	103
Size:	13.5 KB
ID:	1335537 Click image for larger version

Name:	Screenshot 2025-02-22 234301.png
Views:	82
Size:	17.1 KB
ID:	1335538 Click image for larger version

Name:	Screenshot 2025-02-22 234321.png
Views:	78
Size:	47.2 KB
ID:	1335539 Click image for larger version

Name:	Screenshot 2025-02-22 234357.png
Views:	79
Size:	76.6 KB
ID:	1335540

    #2
    I feel we would need to see more of the code to figure this out. Have you tried turning TraceOrders to true? That should also tell you if you are entering a trade and when that gets submitted. Have you tried it before and it showed when your stops and targets were not null? If you haven't seen it register as anything other than null then perhaps those variables aren't being assigned properly? Or maybe they are being set to null when they are not supposed to?

    Comment


      #3
      Hello HappyTrader76,

      Attached is a modified version of the ProfitCaseStopTrailIndicatorExample found here:
      ProfitChaseStopTrailIndicatorExample_NT8.zip

      I've added prints for when the variables are reset to null and prints the orderUpdateArgs.Order information.

      Please run this let me know if this reproduces. If so, please provide the output saved to a text file.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by rockmanx00 View Post
        I feel we would need to see more of the code to figure this out. Have you tried turning TraceOrders to true? That should also tell you if you are entering a trade and when that gets submitted. Have you tried it before and it showed when your stops and targets were not null? If you haven't seen it register as anything other than null then perhaps those variables aren't being assigned properly? Or maybe they are being set to null when they are not supposed to?
        Hi rockmanx00, the variables did actually show orderstates Working and PartFilled. But after scrutinizing my code I found the problem. As you mentioned in your last question, I did accidentally set them null with a change that I made previously. So the problem is solved. Thank you for your effort!

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello HappyTrader76,

          Attached is a modified version of the ProfitCaseStopTrailIndicatorExample found here:
          [ATTACH]n1335656[/ATTACH]

          I've added prints for when the variables are reset to null and prints the orderUpdateArgs.Order information.

          Please run this let me know if this reproduces. If so, please provide the output saved to a text file.
          Hi ChelseaB, I think I found my bug but I'll love to learn more through your example. Thank you for your effort!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 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
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X