Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit orders being ignored...but not always

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

    Exit orders being ignored...but not always

    Having an issue where my strat will place an order, and place a stop and limit target, then I quickly update them. most of the time it seems to respect the stop and target, and sometimes it just goes right past it and I don't have any errors, no logs of interest, the strat doesn't crash out. below is the code i use to set order and stop and limit. Wondering if I am missing something regarding my advanced order management rules or maybe if this code runs multiple times maybe that could cause an issue. Please excuse the base template being from other available public code. I have mostly gutted it and everything of importance is in onbarupdate and the click events for the 4 buttons

    my code to enter orders:
    Click image for larger version

Name:	image.png
Views:	81
Size:	25.4 KB
ID:	1337949

    there is a section that sets stops incase I don't fill in numbers , but this is the section that sets stop and target after that:
    Click image for larger version

Name:	image.png
Views:	81
Size:	22.8 KB
ID:	1337950​​
    Attached Files

    #2
    forgot to show example of it ignoring:
    Click image for larger version

Name:	image.png
Views:	81
Size:	16.9 KB
ID:	1337953
    other times it is 30 40 points past... but this is what I could get before I had to finish this post​​
    Attached Files

    Comment


      #3
      Hello gkulick,

      Enable TraceOrders.

      Print the order.ToString() in OnOrderUpdate().

      Provide the output from the output window saved to a text file.

      Note the date and time you are expecting the order to be submitted.

      Below is a link to a support article on adding debugging prints to understand behavior.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        ok attached are the logs. entry was a buy stop at that was triggered on the 14:47 candle, stops were then added and adjusted, and then nothing logged for the limit being crossed in this image:
        Click image for larger version  Name:	image.png Views:	0 Size:	27.4 KB ID:	1337973
        logs.txt

        Comment


          #5
          logs related to this order start on line 161, then continue lower

          Comment


            #6
            Hello gkulick,

            Enable TraceOrders.

            Either set TraceOrders = true; in State.Configure, or set TraceOrders = true; in State.SetDefaults and remove the instance of the strategy from the chart and add a new instance.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks Chelsea, I read through the logs and the issue seems to have been, I was setting some initial stop/targets and then in the same tick or next tick I was setting new ones, this looks to have been causing maybe a race condition or other issues as the first orders might have been in the middle of getting set when the new orders get called. I have since eliminated the need for such a structure in my code and everything is working nicely.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              116 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              61 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              40 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              43 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              82 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X