Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with ChangeOrder()

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

    Problems with ChangeOrder()

    Hi!

    I get always the error:
    'ChangeOrder' only can be called on unmanaged strategies

    The code looks like this:

    Code:
    IOrder orderLong = null;
    doube price = 0.0;
    -----
    EnterShort(1,"");
    price = 8000.0;
    orderLong = EnterLongLimit(1,7990.0);
    if(orderShort != null) {
    ChangeOrder(orderLong,1,8004.0,0.0);
    }
    What is wrong with the ChangeOrder?

    Thank you!

    Kind regards, plizer

    #2
    plizer, ChangeOrder is specific to the unmanaged order submission mode only. Since you're in managed mode here, just resubmit your order at the new price to update it.

    Comment


      #3
      Thank you for the fast reply.

      The service in this forum is really great! Keep it up! :-) (even when some of the questions are stupid the supporters do such a good job)

      Comment


        #4
        You are welcome, we're always glad to assist.

        Comment


          #5
          just resubmit your order at the new price to update it.
          I tried:
          orderShort = EnterShortLimit(1,price);

          But the problem is, that there will be thousands of orders. I tried Clear() or Remove(), but nothing works. orderShort is the type IOrder

          How can i start a new order with "EnterShortLimit" and delete the other limit orders?
          Last edited by plizer; 09-23-2013, 04:59 AM.

          Comment


            #6
            plizer, would suggest you debug with the TraceOrders what exactly is occurring in your setup here.



            The order per default will expire at the end of the bar you placed it on, if you did not submit it in via liveUntilCancelled set to 'true' in the advanced overload.

            If the order was working still and you submit it again with a changed limit price, the order would be updated in the managed mode. Via a submit order call in unmanaged in contrast you would create a new order each time and for changing and explicit ChangeOrder call would be needed.

            Where do you reset your IOrders to null?

            Generally helpful examples in those areas would be http://www.ninjatrader.com/support/f...ead.php?t=7499

            When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until

            Comment


              #7
              The cource code was too big for me to find what causes the errors. So I try to get a simple code:

              Code:
              protected override void OnBarUpdate() {
              if(Position.MarketPosition == MarketPosition.Flat) {
              EnterShort(1,""); // -->the chart shows the correct trade! SELL at 8622.0.
              EnterLongLimit(1,8600); // -> this order has never been executed!
               }
              }
              The price falls below 8600 and the EnterLongLimit is completely ignored? Why?

              Comment


                #8
                Would suggest to run with TraceOrders enabled to help you debug - http://www.ninjatrader.com/support/f...ead.php?t=3627

                Would expect to see an ignore based on your EntryHandling settings for the script -

                Comment


                  #9
                  I activated TraceOrders but cant see a different. The error message is the same as before. I cant find additional information. Also english is not my best language...

                  23.09.2013 16:27:13 Strategy An Enter() method to submit an entry order at '18.09.2013 08:24:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
                  23.09.2013 16:27:13 Strategy Enabling NinjaScript strategy 'MyScript/4d76a38d7f744572a2afa80c0488a2a2' : 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 CalculateOnBarClose=False MaxRestarts=4 in 5 minutes
                  23.09.2013 16:27:13 Strategy Disabling NinjaScript strategy 'MyScript/4d76a38d7f744572a2afa80c0488a2a2'

                  Comment


                    #10
                    You would be running into the internal order handling rules of the managed approach here, as both orders in your call would be sent on the same OnBarUpdate() and NT would avoid that 2 concurrent orders are processed as a safeguard. If you would place your target limit order with the SetProfitTarget method for example > it would wait until the entry has been executed and thus reporting filled and then only would submit in the limit exit order for you.

                    orderShort = EnterShort(1,""); // -->the chart shows the correct trade! SELL at 8622.0.
                    SetProfitTarget(CalculationMode.Price, 8600);

                    Another more advanced approach would be monitoring from the OnExecution() method when the entry would report filled and then send you exit's as desired manually. That's the process shown in the first sample I posted earlier in this thread.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    663 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    376 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    110 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    575 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    580 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X