Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7 SampleOnOrderUpdate

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

    NT7 SampleOnOrderUpdate

    NT Team,

    Would it be possible to provide the sample strategy "SampleOnOrderUpdate" with all appropriate changes for use in NT7?

     IExecution.IOrder property will now reflect the order state at the time of OnExecution() meaning it could return values ahead of the currently being processed IExecution.

    o Ex: There can be discrepancies between IExecution.Order.Filled and IOrder.Filled as accessed during order placement
     IOrder objects are now unique throughout the lifetime of a strategy

    o Do NOT hold onto .Token values since they will change as the strategy goes from historical to live

    o To check for equality you can directly compare IOrders. Example:
    if (entryOrder == order)

    o IOrder.Action has been renamed to IOrder.OrderAction
    Regards
    Shannon

    #2
    Hi Shannon, thanks for the suggestion / request - we're currently updating those and will post them when ready.

    Comment


      #3
      SampleOnOrderUpdate: exitOrder?

      Hello:

      I have reviewed all threads on SampleOnOrderUpdate for NT6.5 and would like to suggest additional code to add to the NT7 version. Please add an example that provides a way to exit an order without a stopOrder or targetOrder combination. Perhaps this can be incorporated within the code already written. To me, this would be a great help in determining the ideal way to incorporate the code into my software. Perhaps there is already an easy example available that I have missed. Thanks.

      Tony

      Comment


        #4
        Tony,

        I guess I am not quite sure I follow. If you do not want to use a stop/target, just submit whatever order you want to use to close your position at the point in time you want to exit.

        For instance, if you want to close your position after 10 bars have passed you could do something like

        Code:
        if (Position.MarketPosition == MarketPosition.Long && BarsSinceEntry() > 10)
             ExitLong();
        You can use market orders like shown above or any other order type to do your exit like limit orders or stop orders.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          exitOrder combined with stopOrder and targetOrder

          Hello Josh:

          I guess I wasn't as clear as I should have been. I wanted to include stopOrder and targetOrder, but also include certain situations to exit before price reaches these orders. My questions are:

          1. Where can an exitOrder (ExitLong()) be included within SampleOnOrderUpdate code?

          2. Will the code automatically cancel the stopOrder and targetOrder trades should this exitOrder occur?

          Thanks.

          Tony

          Comment


            #6
            Tony,

            You can call ExitLong() whenever you want wherever you want. When you deem it is time to close the trade, just call your order to close the position. You should exercise caution when you do this if you are trying to close the position close to where the stop/target is as you may run the risk of an overfill where both orders get filled if you do this. If you are far away from stop/targets you would not need to worry about this. Safest way to do this is to just modify your stop order up above the market to get it instantly filled. NT will automatically handle cancelling out the target after your stop gets filled.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Excellent Exit out of Position!

              Thanks Josh. Changing stopOrder to Close[0] + n ticks to automatically exit a long position makes much better sense to me. I assume this exits the long position as a Market order. It also has the added benefit of closing out the targetOrder order. Thanks again.

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                Hi Shannon, thanks for the suggestion / request - we're currently updating those and will post them when ready.
                Hey Bertrand,

                Understanding you guys are under the pump at the moment, any ETA on the sample strategy code (e.g. "SampleOnOrderUpdate") with all appropriate changes for use in NT7?

                As always, thanks
                Shannon

                Comment


                  #9
                  Hi Shannon, I would unfortunately not have an ETA on this - the main change going from 6.5 to 7 is that you can compare the IOrder object now directly (6.5 needed the tokens) - http://www.ninjatrader.com/support/h...nt7/iorder.htm

                  Comment


                    #10
                    Bertrand,

                    In the NT7 online help guide, the OnExecution() method still uses tokens were OnOrderupdate does not. Is this correct?

                    http://www.ninjatrader.com/support/h...nt7/index.html -> OnExecution()

                    Examples
                    private IOrder entryOrder = null;

                    protected override void OnBarUpdate()
                    {
                    if (entryOrder == null && Close[0] > Open[0])
                    entryOrder = EnterLong();
                    }

                    protected override void OnExecution(IExecution execution)
                    {
                    if (entryOrder != null && entryOrder.Token == execution.Order.Token)
                    Print(execution.ToString());
                    }
                    Regards
                    Shannon

                    Comment


                      #11
                      Shannon,

                      Thank you for the spot. .Token should not be used.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        NT Team,

                        Any hope of an ETA on the NT7 SampleOnOrderUpdate?

                        Regards
                        Shannon

                        Originally posted by NinjaTrader_Bertrand View Post
                        Hi Shannon, thanks for the suggestion / request - we're currently updating those and will post them when ready.

                        Comment


                          #13
                          Shansen,

                          Unfortunately we do not have an ETA, but it will be almost 100% identical. The only notable difference to be made is .Token checks would be removed for the new style of equality checks where you just check IOrder objects directly.

                          For example:
                          Code:
                          protected override void OnOrderUpdate(IOrder order)
                          {
                               if (entryOrder == order)
                                    // Do something;
                          }
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Josh,

                            Thanks for the reply. You confirmed my understanding of Tokens in NT7.
                            Though I'm still having difficulty in applying IOrders in NT7 (No problems in NT6.5)

                            As an experiment I imported into NT7 a clean copy of the "SampleOnOrderUpdate" NinjaScript (aware it is designed for NT6.5). As expected the NinjaScript compiled fine, and executed perfectly, no problems in the Control Center Log. I added TraceOrders = true to the Initialize section, compiled and exectued again, no problems in the Control Center Long or Output window.

                            Editing the NinjaScript, a simple replace ".Token" with null (i.e. nothing) removed the 8 references to Tokens. The NinjaScript compiled fine. On execution, an error was reported in the Control Center Log "A Sell stop order placed... Please fix your strategy."

                            Where is it all going wrong?
                            Regards
                            Shannon

                            Comment


                              #15
                              Shannon, can you please post the script you used for testing so we may comment and check into?

                              Thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              607 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              353 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
                              560 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              561 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X