Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help in Order Management

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

    Need help in Order Management

    I am new to Order management .
    1. I have used “EnterShortLimit(10000,Se, "Sell");” and “ExitShortLimit(St, Sel.FromEntrySignal);” in my routine. If my strategy opens multiple positions, should I need to allow for updating of “string signalName” in the routine?

    2. I also see a version “ExitShortLimit(doublelimitPrice,string signalName,stringfromEntrySignal)”. “signalName” and “fromEntrySignal” point to the same position. what is the advantage of giving both? There should be some logic or I misunderstood the usage.

    3. Can I update the “limitPrice” in “ExitShortLimit” for every bar update?

    Many thanks.

    This function is call for every bar update.

    privatevoid Ordman()
    {
    int Rf, Sf;
    double Se, Ss, St;
    IOrder Sel;
    Rf = Rsdata.Count-1;
    Sf = Ssdata.Count-1;
    if(Rsdata.Count>0)
    {
    Se= ((Reslh)Rsdata[Rf]).l; // Entry limit
    Ss= ((Reslh)Rsdata[Rf]).h; // Stop limit
    St= ((Reslh)Rsdata[Rf]).tr;// Target limit
    Sel=EnterShortLimit(10000,Se, "Sell");

    }
    ExitShortLimit(St, Sel.FromEntrySignal); // St = Target limit

    }

    #2
    Hello,

    1- Yes. I suggest using a combination of a string variable and adding the CurrentBar value to the string variable to maintain unique signal names.

    2- The "from..." part refers to the signal that this order will act on. The "signalName" part is the signal of that order itself.

    3- Yes. You basically maintain the limit orders by resubmitting them every bar.

    Hope that helps!
    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks Ben for your help.

      I am tring the following code and at a stage my routine gets an error message. Can you please help me what values are to be printed onto output screen to check the validity?
      I give my code below.

      Oref.tm= ((Reslh)Rsdata[Rf]).tm;

      Oref.op= ((Reslh)Rsdata[Rf]).l;
      // Sell Entry limit
      Oref.st= ((Reslh)Rsdata[Rf]).h; // Stop limit
      St = Oref.op-(Oref.st-Oref.op);// Target limit as Removeing Risk

      Oref.or1=EnterShortLimit(
      20000,Oref.op, "Sell" + Scon);

      ExitShortStop(Oref.st,(Oref.or1).FromEntrySignal);
      ExitShortLimit(St,(Oref.or1).FromEntrySignal);
      Print((Oref.or1).FromEntrySignal);
      // A blank line is printed here
      Oref.or2=EnterShortLimit(10000,Oref.op, "Sello" + Scon);
      Print(
      "Test1");Print(Oref.st); // Values are ok up to here
      Print((Oref.or2).FromEntrySignal); // I get an error message Routine stops
      Print("Test2");
      ExitShortStop(Oref.st,(Oref.or2).FromEntrySignal);
      Print(
      "Test3");

      Comment


        #4
        malmaa, which exact error message do you get? Have you already enalbed TraceOrders to check into the order behavior you get?

        Comment


          #5
          Hello Bertrand,
          I get this message after enabling trace orders.
          It appears that Third statement in order managemment gives an ignored message.
          I used one statement for entry, One for stop and one for limit.
          Is it that we cannot use two statements for exits(stop and profit limit)?

          Many thanks



          Inside Order Management
          0
          1/8/2010 1:15:00 PM Entered internal PlaceOrder() method at 1/8/2010 1:15:00 PM: Action=SellShort OrderType=Limit Quantity=0.02M LimitPrice=1.5996 StopPrice=0 SignalName='Sell0' FromEntrySignal=''
          1/8/2010 1:15:00 PM Entered internal PlaceOrder() method at 1/8/2010 1:15:00 PM: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1.6006 SignalName='' FromEntrySignal=''
          1/8/2010 1:15:00 PM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1.6006 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
          1/8/2010 1:15:00 PM Entered internal PlaceOrder() method at 1/8/2010 1:15:00 PM: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=1.5986 StopPrice=0 SignalName='' FromEntrySignal=''
          1/8/2010 1:15:00 PM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=1.5986 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
          1/8/2010 1:15:00 PM Entered internal PlaceOrder() method at 1/8/2010 1:15:00 PM: Action=SellShort OrderType=Limit Quantity=0.01M LimitPrice=1.5996 StopPrice=0 SignalName='Sello0' FromEntrySignal=''
          1/8/2010 1:15:00 PM Ignored PlaceOrder() method at 1/8/2010 1:15:00 PM: Action=SellShort OrderType=Limit Quantity=0.01M LimitPrice=1.5996 StopPrice=0 SignalName='Sello0' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
          Test1
          1.6006
          **NT** Error on calling 'OnBarUpdate' method for strategy 'Resandsup/cc29a7a201f64cb8b0f195031dcddef7': Object reference not set to an instance of an object.
          1/8/2010 1:15:00 PM CancelAllOrders: BarsInProgress=0

          Comment


            #6
            malmaa, it's just ignored as there's no open position to exit from (expected) - are you synched up as needed?

            Comment


              #7
              Thank you Bertrand for your reply,
              I have figured out that
              1. When I open a short, and apply Stop and Limit orders to it. This doesn’t work with “Entries per direction” is set to “1”. I had to set to “3” to work(even 2 doesn’t work). Is it because that I use three statements for the same order.
              2. I read “Strategy Position Vs Account Position” it is bit difficult to understand. As I understand we have to go for “True in sync” option if we trade just the strategy and “False in sync” option if we use Super DOM along with our strategy. Essentially it appears it’s better go with “False in sync” option as it works for both strategy and Super DOM. Can we handle this situation in Strategy logic? Am I in the right direction?

              Regards

              Comment


                #8
                1. Correct, because you uniquely named them, EntriesPerDirection 1 combined with Unique order handling should work as well.

                2. Not sure I follow what you mean by 'True in sync' option - are you referring to NT7's autoSync feature? For 6.5 it means if you do not use 'WaitUntilFlat' > you would need to ensure the Strategy Vs Account position is in sync, and if not you would needed to place a manual order upon startup to makeup for any different position sizes you saw.

                Comment


                  #9
                  Yes Bertrand I am referring to NT7.
                  Great info for today. Support forum is definitely a great way to learn.
                  Thanks a lot.
                  Cheers

                  Comment


                    #10
                    If you are manually trading as well as using a strategy you would not want to use sync as that may close your manually trading positions.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Thankyou Josh for your help.

                      I am using two sets of statements First set for Short orders and Second set for Long orders.
                      After the execution of first Long order (i.e. in Second set), I get an error message.
                      Can some one help me understand this error message please?

                      Settings I use:
                      Entries per direction=30,
                      Entry Handling = AllEntries,
                      Stop&Target Submission= ByStrategyPosition.
                      On starting the real-time strategy = Wait until flat before executing live.

                      Code:

                      Print("Enter Short order");
                      Orefs.tm= ((Reslh)Rsdata[Rf]).tm;
                      Orefs.op= ((Reslh)Rsdata[Rf]).l; // Sell Entry limit
                      Orefs.st= ((Reslh)Rsdata[Rf]).h; // Stop limit
                      St = Orefs.op-(Orefs.st-Orefs.op);// Target limit as Removeing Risk
                      Print("Entry");Print(Orefs.op);Print("Stop");Print(Orefs.st);Print("Target");Print(St);

                      Orefs.or1=EnterShortLimit(20000,Orefs.op);
                      ExitShortStop(Orefs.st,(Orefs.or1).FromEntrySignal );
                      ExitShortLimit(St,(Orefs.or1).FromEntrySignal);

                      Orefs.or2=EnterShortLimit(10000,Orefs.op);
                      ExitShortStop(Orefs.st,(Orefs.or2).FromEntrySignal );
                      ExitShortLimit(St,(Orefs.or2).FromEntrySignal);

                      Print("Enter Long order");
                      Orefl.tm= ((Reslh)Ssdata[Sf]).tm;
                      Orefl.op= ((Reslh)Ssdata[Sf]).h; // Sell Entry limit
                      Orefl.st= ((Reslh)Ssdata[Sf]).l; // Stop limit
                      St = Orefl.op+(Orefl.op-Orefl.st);// Target limit as Removeing Risk
                      Print("Entry");Print(Orefl.op);Print("Stop");Print(Orefl.st);Print("Target");Print(St);

                      Orefl.or1=EnterLongLimit(20000,Orefl.op);Print("Test1");
                      ExitLongStop(Orefl.st,(Orefl.or1).FromEntrySignal) ;Print("Test2");
                      ExitLongLimit(St,(Orefl.or1).FromEntrySignal);

                      Orefl.or2=EnterLongLimit(10000,Orefl.op);
                      ExitLongStop(Orefl.st,(Orefl.or2).FromEntrySignal) ;
                      ExitLongLimit(St,(Orefl.or2).FromEntrySignal);

                      Output Window:

                      Enter Short order
                      Entry
                      1.598
                      Stop
                      1.6
                      Target
                      1.596
                      12/30/2009 4:15:00 AM Entered internal PlaceOrder() method at 12/30/2009 4:15:00 AM: Action=SellShort OrderType=Limit Quantity=0.02M LimitPrice=1.5980 StopPrice=0 SignalName='' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Amended open order: Action=SellShort OrderType=Limit Quantity=20000 LimitPrice=1.5980 StopPrice=0 SignalName=Sell short' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Entered internal PlaceOrder() method at 12/30/2009 4:15:00 AM: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1.6000 SignalName='' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1.6000 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
                      12/30/2009 4:15:00 AM Entered internal PlaceOrder() method at 12/30/2009 4:15:00 AM: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=1.5960 StopPrice=0 SignalName='' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=1.5960 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
                      12/30/2009 4:15:00 AM Entered internal PlaceOrder() method at 12/30/2009 4:15:00 AM: Action=SellShort OrderType=Limit Quantity=0.01M LimitPrice=1.5980 StopPrice=0 SignalName='' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Amended open order: Action=SellShort OrderType=Limit Quantity=10000 LimitPrice=1.5980 StopPrice=0 SignalName=Sell short' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Entered internal PlaceOrder() method at 12/30/2009 4:15:00 AM: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1.6000 SignalName='' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1.6000 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
                      12/30/2009 4:15:00 AM Entered internal PlaceOrder() method at 12/30/2009 4:15:00 AM: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=1.5960 StopPrice=0 SignalName='' FromEntrySignal=''
                      12/30/2009 4:15:00 AM Ignored PlaceOrder() method: Action=BuyToCover OrderType=Limit Quantity=0 LimitPrice=1.5960 StopPrice=0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'
                      Enter Long order
                      Entry
                      1.5887
                      Stop
                      1.5879
                      Target
                      1.5895
                      12/30/2009 4:15:00 AM Entered internal PlaceOrder() method at 12/30/2009 4:15:00 AM: Action=Buy OrderType=Limit Quantity=0.02M LimitPrice=1.5887 StopPrice=0 SignalName='' FromEntrySignal=''
                      Test1

                      Comment


                        #12
                        malmaa, you would see this you just submit the Exit() orders and do not check if you have an open corresponding position at the submit time, as Exit() methods would be ignored if you don't have a matching position to exit from, thus seeing this is expected behavior.

                        Comment


                          #13
                          Thankyou Bertrand for your reply,

                          1. Do you mean to say that Orders should be OPENED in the market already executed. And then we have to use “on execution” to set the stop and profit limits.
                          2. Can’t we set the entry, stop and profit limits to an order and then push it into the market?
                          3. Reg: OnExecution() method;
                          a. I enter into market using “EnterShortLimit(intquantity, doublelimitPrice,stringsignalName)” which returns a “IOrder” object. Upon execution “OnExecution()” returns another “IOrder” object. Will the user given “signalName” remain the same in both the “IOrder” objects? If not, is their any attribute attached to the order that remains same till its expiry?
                          b. If I initiate two limit orders at the same price, will this result in calling “OnExecution(IExecution execution)” two times with corresponding IExecution objects?

                          Regards,

                          Comment


                            #14
                            1) Bertrand means that, in your script, you call Exit() methods before you have a position opened. They are being ignored because there is no position to exit.

                            2) You can send the orders to the market. If you match up the ExitStop() and ExitLimit() fromEntrySignals, the orders will be one-cancels-other and will act like a stop and target should.

                            3a) You can check IOrders directly:
                            Code:
                            OnExecution(IOrder execution)
                            {
                                if (execution == someIOrder)
                                    // do something
                            }
                            3b) There will be as many OnExecution() as there are executions/fills. If you submit an order to buy 100 contracts, there could be up to 100 calls of OnExecution() or there could be just one call with 100 for the quantity filled.
                            AustinNinjaTrader Customer Service

                            Comment


                              #15
                              Austin,
                              Your reply to 1 and 2 appear contradicting each other.
                              1. You said that my Exit methods were ignored because I do not have an open position. This implies that we need an open position in market to set stop and profit limits.
                              2. You say that we can set stop and profit limits to an entry order (fromEntrySignals) and then open into the market. This is what I have done and received the error message.
                              3. It is interesting to know that we can compare IOrders. And finally Will signalName/fromEntrySignals remain constant through out the life of a particular order?
                              Regards,

                              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