Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaTrader crashes when I load strategy with CancelOrder()

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

    NinjaTrader crashes when I load strategy with CancelOrder()

    The script is approx. like below. I had no problem before adding CancelOrder() and IOrder. Don't know which caused the crash. Could you have a look?



    private IOrder myEntryOrder = null;
    private int barNumberOfOrder = 0;

    protected override void OnBarUpdate()
    {

    {

    myEntryOrder = null;

    myEntryOrder = EnterLongLimit(0, true, 1, Low[0], "Long Entry");
    barNumberOfOrder = CurrentBar;
    }


    if (CurrentBar > barNumberOfOrder + 3)
    CancelOrder(myEntryOrder);
    }

    #2
    I tested it in my another machine, and it still crashes when I load the script.

    Comment


      #3
      Please chech the log tab for errors when this happens.

      You don't want to reset your IOrder entry order object to null each time the OnOrderUpdate() is called, so just check if it's null and then place the entry -

      Code:
       
      if (myEntryOrder == null) 
      {
      myEntryOrder = EnterLongLimit(0, true, 1, Low[0], "Long Entry"); 
      barNumberOfOrder = CurrentBar; 
      }

      Comment


        #4
        Originally posted by NinjaTrader_Bertrand View Post
        Please chech the log tab for errors when this happens.

        You don't want to reset your IOrder entry order object to null each time the OnOrderUpdate() is called, so just check if it's null and then place the entry -

        Code:
         
        if (myEntryOrder == null) 
        {
        myEntryOrder = EnterLongLimit(0, true, 1, Low[0], "Long Entry"); 
        barNumberOfOrder = CurrentBar; 
        }
        strange that I deleted the whole IOrder codes from my script, and it still crashes. Does NinjaTrader have memory or sth?

        Comment


          #5
          I found that it's not my particular strategy cause the crash now. I went to Strategy tab, right click, new strategy, and then NT crashes.

          But before I used the IOrder script, NT was fine running any strategy.

          Comment


            #6
            leontancfa,

            After making any changes to code you will need to recompile and also start a new instance of the script. We will need more information on what you mean by "crash". Please provide trace/log files.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              leontancfa,

              After making any changes to code you will need to recompile and also start a new instance of the script. We will need more information on what you mean by "crash". Please provide trace/log files.
              where are those files?

              Comment


                #8
                My Documents\NinjaTrader 6.5\trace folder and the log folder.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                562 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                325 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
                547 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