Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Beta 23 bug, Inconsistent multi-Instrument end of session order handling

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

    Beta 23 bug, Inconsistent multi-Instrument end of session order handling

    Orders placed at the end of session (16:00 EST) are handled differently in v23.
    When TIF = day
    In v22 both primary and secondary instrument orders are placed and canceled at end of session, 4:00pm.
    In v23 both primary and secondary instrument orders are placed, but only the primary instrument is canceled. The secondary order is entered at the start of the next session.

    This is inconsistent, and changes backtest results.
    If time in force = day, no order should be carried to the next session.

    A simple test program is attached.
    Set the UI as shown in the code comment.
    Observe the results the output window at 4:00

    junk7.cs

    #2
    Hello Camdo,

    Your strategy uses market orders in a backtest. There is no end of session handling done related to the TIF setting used. With market orders in a backtest. If the conditions evaluate true, then a position is opened on the bar following the condition.

    TIF applies only to active orders, and in a backtest these would be stop, stop limit, limit with liveUntilCanceled set to true.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan
      The test executes EnterLong for both primary and secondary instrruments at 16:00.
      If what you say is true, then it is logically inconsistent that only the secondary instrument is entered on the next bar (which is the first bar of the next session).

      In a backtest,
      If TIF = GTC then both instruments are entered the next session.
      if TIF = Day then only the secondary instrument is entered the next session.
      Therefore TIF is having an effect on market orders too.

      Comment


        #4
        Can you please share these details and I'll setup a similar test.

        Who is your data provider?
        What is the primary bar series?
        What session template are you using?
        What time zone are you using?
        Can you try with an instrument that trades on Dow 30 so we don't have to set up BGU? Let us know if you're still seeing it and which instrument.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          Data provider: MB Trading
          Session Template: US Equities RTH
          Time zone: GMT-05:00 Eastern Time
          Primary bar series: AA, 1 minute, Last
          change line 46 of test strategy to: "GE" 1 minute
          time frame 11/2/2010 - 11/3/2010
          Entry/dir = 2
          Entry handling = All Entries
          Exit on Close = True
          Qty = by strategy
          TIF = Day

          I tested with the above settings, results are the same.
          Observe in the output window at 11/3/2010 9:31 that AA is flat and GE is long

          Comment


            #6
            I get the same results whether TIF is set to GTC or Day.

            GTC:
            2010-11-03 7:31:00 Positions[0] = Instrument='AA' Account='Backtest' Avg price=0 Quantity=0 Market position=Flat Positions[1] = Instrument='GE' Account='Backtest' Avg price=0 Quantity=0 Market position=Flat

            Day:
            2010-11-03 7:31:00 Positions[0] = Instrument='AA' Account='Backtest' Avg price=0 Quantity=0 Market position=Flat Positions[1] = Instrument='GE' Account='Backtest' Avg price=0 Quantity=0 Market position=Flat

            Both positions are flat on first bar of 11-3-10, regarless of TIF setting. This is due to ExitOnClose handling.

            I would add TraceOrders = true; to your strategies Initialize() method so you can see what else is going on with your strategy.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi Ryan
              There is something wrong with your setup. The output window should only list session times between 9:30 and 16:00 (4:00 pm).

              TraceOrders = true is in the initialize section.

              For US Equities RTH, the market opens at 9:30 and closes at 4:00 pm.
              Last edited by Camdo; 11-05-2010, 10:02 AM.

              Comment


                #8
                My US equities RTH template is using 4:15 Eastern as the closing time. If yours is different, can you post a screenshot of your US equities RTH?

                I adjusted the entry condition two hours back since I'm on Mountain time.

                Attached is my output from both tests, added TimeInForce to the print statement. Let me know if there's something else I need to change to duplicate this test.
                Attached Files
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  The strategy entry time must match the session end time.
                  That is the critical condition.
                  The output should show 2 entries at exactly the session close time.
                  Your session ends at 4:15, so the strategy if statement should be changed to 161500.

                  Your output does not show entry at the exact session close, so the test is not valid.

                  I have atached a screen shot of my session template.
                  I would suggest using the same session settings and time zone to make everything equal.

                  101105-1.zip
                  Last edited by Camdo; 11-05-2010, 11:46 AM.

                  Comment


                    #10
                    Here is my output file. The instrument is different, but that does not matter.

                    Junk7Output.zip

                    Comment


                      #11
                      I've tried different combinations. Different time zones, session templates, and TIF has not changed the results.

                      If you feel TIF impacts market entry orders in a backtest, simplify your strategy a bit more. Remove stop loss and profit target orders and change ExitOnClose handling to false.

                      Look at the session template applied to both instruments. Since you had adjusted the definitions for US equities RTH, the secondary series may be using a different session template than the primary.

                      The session template of the added Bars object will be the default one set for that instrument in the Instrument Manager and not the session template of the primary Bars object.
                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      599 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      344 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      558 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      557 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X