Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help in Order Management

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

    #31
    Hi Bertrand,

    So for NT6.5, can we divide the strategy in to two different strategies one handling only Longs and other handling only Shorts to overcome the Handling rules?
    2. I have a beta version of NT7. where can I get info regarding SubmitOrder(), ChangeOrder() and CancelOrder() methods?

    Comment


      #32
      malmaa, yes this would be a workaround - or just monitor the last price and thus submit only one order as needed.

      On NT7's unmanaged order submission approach you could check into this thread - http://www.ninjatrader-support2.com/...ad.php?t=21091

      Comment


        #33
        I initially assigned values for IOrders for Entry,Stop and Profit limits.
        After some process I like to update the “stoploss” in onbarupdate. Do we have to reassign output value of “EntryStopLimit” to “Stop1” or will it be automatically updated?

        IOrder Enter1=null,Stop1=null,Limit1=null;
        protectedoverridevoid OnBarUpdate()
        {
        Enter1= EnterLong(10000, "Long1");}
        protectedoverridevoid OnExecution(IExecution execution)
        {
        Limit1=ExitLongLimit(Position.AvgPrice + 100 * TickSize, Enter1.FromEntrySignal);
        Stop1=ExitLongStop(Position.AvgPrice - 100 * TickSize,Enter1.FromEntrySignal);
        }
        After some process updating the stoploss in Onbarupdate:
        protectedoverridevoid OnBarUpdate()
        { ExitLongStop(Position.AvgPrice,Enter1.FromEntrySig nal);// “Stop1” variable not assigned in my statement. Is this ok?
        }
        Last edited by malmaa; 01-16-2010, 06:45 AM.

        Comment


          #34
          Originally posted by malmaa View Post
          I initially assigned values for IOrders for Entry,Stop and Profit limits.
          After some process I like to update the “stoploss” in onbarupdate. Do we have to reassign output value of “EntryStopLimit” to “Stop1” or will it be automatically updated?

          After some process updating the stoploss in Onbarupdate:
          protectedoverridevoid OnBarUpdate()
          { ExitLongStop(Position.AvgPrice,Enter1.FromEntrySig nal);// “Stop1” variable not assigned in my statement. Is this ok?
          }
          You have to reassign the value:
          Code:
          OnBarUpdate()
          {
              Stop1 = ExitLongStop(new stop details);
          }
          AustinNinjaTrader Customer Service

          Comment


            #35
            What I am trying to do is
            1. To open two long positions.
            2. Set stop and Limit to first Position
            3. Set Stop to second Position.
            If the use the “EnterShortLimit” on the first order, I am to “EnterShortStop” on the second order.
            Is it that we have to use only “EnterShortLimit” or “EnterShortStop” but not both?

            I am opening two long positions
            Orefs.oe1=EnterShortLimit(0,true,20000,Orefs.op,"Shortf" + Scon);
            Orefs.oe2=EnterShortLimit(0,true,10000,Orefs.op,"Shorth" + Scon);
            . . . . .
            OnExecution(IExecution execution)
            {

            if (execution.Order.Action==Action.SellShort){
            if ((execution.Order).Token==((Shortord[Sno]).oe1).Token){

            Ortmp.os1 = ExitShortStop(0,true,20000,((Shortord[Sno]).st),((Shortord[Sno]).oe1).Name + "S",((Shortord[Sno]).oe1).Name); //Stop order for First trade
            Ortmp.ot1 = ExitShortLimit(0,true,20000,St,((Shortord[Sno]).oe1).Name + "L",((Shortord[Sno]).oe1).Name); //Limit order for First trade

            }} // End of OnExecution
            . . . . .

            OnExecution(IExecution execution)
            { if (execution.Order.Action==Action.SellShort){
            if ((execution.Order).Token==((Shortord[Sno]).oe2).Token){
            Ortmp.os2 = ExitShortStop(0,true,10000,((Shortord[Sno]).st),((Shortord[Sno]).oe2).Name + "S",((Shortord[Sno]).oe2).Name); //Stop order for Second trade

            }}
            } // End of OnExecution

            Output Window:
            Enter Short orders
            1/5/2010 1:15:00 AM Entered internal PlaceOrder() method at 1/5/2010 1:15:00 AM: Action=SellShort OrderType=Limit Quantity=0.02M LimitPrice=1.6118 StopPrice=0 SignalName='Shortf0' FromEntrySignal=''
            1/5/2010 1:15:00 AM Entered internal PlaceOrder() method at 1/5/2010 1:15:00 AM: Action=SellShort OrderType=Limit Quantity=0.01M LimitPrice=1.6118 StopPrice=0 SignalName='Shorth0' FromEntrySignal=''

            Place stop and Limit for First order
            1/5/2010 5:45:00 AM Entered internal PlaceOrder() method at 1/5/2010 5:45:00 AM: Action=BuyToCover OrderType=Stop Quantity=0.02M LimitPrice=0 StopPrice=1.6136 SignalName='Shortf0S' FromEntrySignal='Shortf0'
            1/5/2010 5:45:00 AM Entered internal PlaceOrder() method at 1/5/2010 5:45:00 AM: Action=BuyToCover OrderType=Limit Quantity=0.02M LimitPrice=1.6100 StopPrice=0 SignalName='Shortf0L' FromEntrySignal='Shortf0'

            Place stop for Second order
            1/5/2010 5:45:00 AM Entered internal PlaceOrder() method at 1/5/2010 5:45:00 AM: Action=BuyToCover OrderType=Stop Quantity=0.01M LimitPrice=0 StopPrice=1.6136 SignalName='Shorth0S' FromEntrySignal='Shorth0'
            1/5/2010 5:45:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00003/Sim101' Name='Shortf0L' State=Working Instrument='$GBPUSD' Action=BuyToCover Limit price=1.61 Stop price=0 Quantity=0.02M Strategy='Resislis' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ebb1c26d7b0242489184953027765d20' Gtd='12/1/2099 12:00:00 AM'

            Comment


              #36
              malmaa, not sure I completely follow you here - as you go short at the same time (OnExecution) you submit the order to close the position...

              Comment


                #37
                My apologies,

                1. To open two Short positions.
                2. Set stop and Limit to first Position
                3. Set Stop to second Position.

                Comment


                  #38
                  malmaa, I see the issue but I am not sure how/why it is occurring because you specify different fromEntrySignals. Could you please either post the complete code here or send it in an email to support at ninjatrader dot com attention 'austin thread 24540'? Thank you.
                  AustinNinjaTrader Customer Service

                  Comment


                    #39
                    Hi there, we've received your strategy and I tried backtesting it but there was an error: Error on calling 'OnBarUpdate' method for strategy 'Resislis': Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index. I added a few print statements to the OnBarUpdate() method and the error came from somewhere in the Res() method.

                    Are there any other settings/properties I should be aware of to test this strategy?
                    AustinNinjaTrader Customer Service

                    Comment


                      #40
                      Dear Austin,
                      Can you please retry on GBPUSD 15 min chart.
                      We need min bars required as 78. it should be more than "fstbar" userinput

                      Comment


                        #41
                        I just tried again with $GBPUSD 15 min chart with min bars set to 80 and received the same error but this time in the OnExecution() method.
                        Attached Files
                        AustinNinjaTrader Customer Service

                        Comment


                          #42
                          Yes we are geting this error near the "Exitshortstop" for the second Short order. we enter two short positions in Ordman(). then we add stop and limits in on execution method.
                          1. we add stop and limit for first position. no problem
                          2. we add stop position for second position we get the error message.

                          3. Plese try to go for entries per direction as 50 (a high number)
                          Last edited by malmaa; 01-19-2010, 05:21 PM. Reason: add info

                          Comment


                            #43
                            malmaa, I thought we were trying to solve this issue (order being cancelled at the wrong time):
                            Place stop for Second order-
                            1/5/2010 5:45:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00003/Sim101' Name='Shortf0L' State=Working Instrument='$GBPUSD' Action=BuyToCover Limit price=1.61 Stop price=0 Quantity=0.02M Strategy='Resislis' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ebb1c26d7b0242489184953027765d20' Gtd='12/1/2099 12:00:00 AM'
                            and not helping you with general debugging of your strategy. You use all sorts of lists, structures, etc that are unsupported by NinjaTrader.

                            That error message stems from the fact that you need to check if many objects are null before accessing them (here is a link to the Checking for Null References tip):
                            Code:
                            if (object != null)
                                Print(object) // or something else
                            If you run the code
                            Code:
                            Print(object)
                            directly, you will receive an error message like the one I encountered while trying to run your strategy.

                            Also, I see you edited your post just now. In the future, please include everything the first time around or else we can get confused and give you a bad/wrong answer.

                            Even after changing entries per direction to 50, I still get the error.

                            Lets get on the same page. What exactly are you trying to fix here? The object reference error?
                            AustinNinjaTrader Customer Service

                            Comment


                              #44
                              Dear Austin,
                              Yes. I also pointed to the same issue. No change. I apologize for my communication if it confused you.
                              I doubted that this issue is something related to “internal Order handling rules”, But now since you say that this a programming error. I will try to debug and get back to you.
                              Many thanks for your time.
                              Regards,

                              Comment


                                #45
                                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.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                648 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                369 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                108 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                572 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                573 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X