Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7 unmanaged ChangeOrder() issue

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

    NT7 unmanaged ChangeOrder() issue

    I am trying to place 2 limit orders, 1 above and 1 below the market, using the simulated data feed. I have included the code below. The code basically puts 2 limit orders, 1 above 1 below every new bar. When I use ChangeOrder() to modify the working orders, I don't see any oreders on my charts, eventhough the TraceOrders output shows that the orders are processed. When I comment out the ChangeOrder() lines, and submit new orders every time, both orders appear on my chart trader.

    Code:
    ---------
    protected override void Initialize() {
    CalculateOnBarClose = true;
    TraceOrders = true;
    Unmanaged = true;
    }

    protected override void OnBarUpdate() {
    double hi = High[1] + (50*TickSize);
    double lo = Low [1] - (50*TickSize);

    Print("");Print("Bar " +CurrentBar +" Buy "+lo +" Sell " +hi);

    //### Buy Limit Below
    if (buyOrder != null) ChangeOrder(buyOrder, 1, lo, 0); else //### Comment out this line for orders to work
    buyOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 1, lo, 0, "", "Buy Below");

    //### Sell Limit Above
    if (sellOrder != null) ChangeOrder(sellOrder, 1, hi, 0); else //### Comment out this line for orders to work
    sellOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Limit, 1, hi, 0, "", "Short Above");
    }


    Output window
    -------------------

    **NT** Enabling NinjaScript strategy 'xxxBlah/66c51e0df95746a18c355e92dc3d58dd' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes

    Bar 20 Buy 1.4364 Sell 1.447
    5/22/2010 9:34:00 AM Entered internal SubmitOrder() method at 5/22/2010 9:34:00 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4364 StopPrice=0 OcoId='' Name='Buy Below'
    5/22/2010 9:34:00 AM Entered internal SubmitOrder() method at 5/22/2010 9:34:00 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4470 StopPrice=0 OcoId='' Name='Short Above'

    Bar 21 Buy 1.4363 Sell 1.4469
    Changing unmanaged order at 5/22/2010 9:34:30 AM: Order='NT-00000/Sim101' Name='Buy Below' State=Working Instrument='6B 06-10' Action=Buy Limit price=1.4363 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ac712be7b02f4216a5926e71da6489e4' Gtd='12/1/2099 12:00:00 AM'
    Changing unmanaged order at 5/22/2010 9:34:30 AM: Order='NT-00001/Sim101' Name='Short Above' State=Working Instrument='6B 06-10' Action=Sell Limit price=1.4469 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='56ad9da0ae344b79bd6810f13a6efe42' Gtd='12/1/2099 12:00:00 AM'
    5/22/2010 9:34:30 AM Entered internal SubmitOrder() method at 5/22/2010 9:34:30 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4469 StopPrice=0 OcoId='' Name='Short Above'

    Bar 22 Buy 1.4361 Sell 1.4464
    Changing unmanaged order at 5/22/2010 9:35:00 AM: Order='NT-00000/Sim101' Name='Buy Below' State=Working Instrument='6B 06-10' Action=Buy Limit price=1.4361 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ac712be7b02f4216a5926e71da6489e4' Gtd='12/1/2099 12:00:00 AM'
    Changing unmanaged order at 5/22/2010 9:35:00 AM: Order='NT-00002/Sim101' Name='Short Above' State=Working Instrument='6B 06-10' Action=Sell Limit price=1.4464 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='817042e03cf0491fae6537f117245437' Gtd='12/1/2099 12:00:00 AM'
    5/22/2010 9:35:00 AM Entered internal SubmitOrder() method at 5/22/2010 9:35:00 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4464 StopPrice=0 OcoId='' Name='Short Above'

    Bar 23 Buy 1.4355 Sell 1.4463
    Changing unmanaged order at 5/22/2010 9:35:30 AM: Order='NT-00000/Sim101' Name='Buy Below' State=Working Instrument='6B 06-10' Action=Buy Limit price=1.4355 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ac712be7b02f4216a5926e71da6489e4' Gtd='12/1/2099 12:00:00 AM'
    Changing unmanaged order at 5/22/2010 9:35:30 AM: Order='NT-00003/Sim101' Name='Short Above' State=Working Instrument='6B 06-10' Action=Sell Limit price=1.4463 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='a538788e6a5447bfa6314b758e24e7fd' Gtd='12/1/2099 12:00:00 AM'
    5/22/2010 9:35:30 AM Entered internal SubmitOrder() method at 5/22/2010 9:35:30 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4463 StopPrice=0 OcoId='' Name='Short Above'
    Last edited by monpere; 05-22-2010, 09:03 AM.

    #2
    monpere,

    I suggest you add some printouts from OnOrderUpdate() to see what happens after ChangeOrder() has been sent.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      monpere,

      I suggest you add some printouts from OnOrderUpdate() to see what happens after ChangeOrder() has been sent.
      I do have a print statement in the code:
      Print("");Print("Bar " +CurrentBar +" Buy "+lo +" Sell " +hi);
      Adding other print statements will not give me any additional information. As you can see in the output from TraceOrders, the statements like "Changing unmanaged order at 5/22/2010 9:34:30 AM: Order='NT-00000/Sim101' Name='Buy Below'..." show that NT did process the ChangeOrder() call, but for some reason the order does not appear on my charts.

      I have given you a reproducible test case, please cut and paste my code into a strategy, run it as is, and observe the behavior. Then comment out the ChangeOrder() lines and observe the difference in behavior. I have also changed the ChangeOrder() lines to CancelOrder() and CancelOrder() works properly, but ChangeOrder() still does not work properly.

      Comment


        #4
        monpere,

        Your printouts are in OnBarUpdate(). Please place print outs into OnOrderUpdate() to truly understand what is happening to your order states after you use ChangeOrder(). Having TraceOrders tells you it processed the code, but it does not tell you what happens after that. You will need to use prints to OnOrderUpdate() to see what happens after that.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          monpere,

          Your printouts are in OnBarUpdate(). Please place print outs into OnOrderUpdate() to truly understand what is happening to your order states after you use ChangeOrder(). Having TraceOrders tells you it processed the code, but it does not tell you what happens after that. You will need to use prints to OnOrderUpdate() to see what happens after that.
          What print statement should I put in OnOrderUpdate? Isn't that what TraceOrders=true is supposed to do, trace every step of my order by putting print statements in my output log? If not, then please tell me what I should be printing.

          Comment


            #6
            monpere,

            No, TraceOrders does not track every single step of the process of an order. That is what OnOrderUpdate() is for. TraceOrders just sees when orders are submitted and if they are rejected/ignored for reasons prior to order submission. For full tracking you would then use OnOrderUpdate().

            This will print everything for every single order on every step of the way for the order.
            Code:
            protected override void OnOrderUpdate(IOrder order)
            {
                 Print(order.ToString());
            }
            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
            629 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            564 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X