Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is correct way to use objects involving cross sesson trades.

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

    What is correct way to use objects involving cross sesson trades.

    What is the correct way to compare objects when the entry was made in a prior session?
    I am using the following code technique with an unmanaged appraoch:

    .
    entryOrder = SubmitOrder(......);
    .
    exitOrder = SubmitOrder(......);
    .
    protected override void OnExecution(IExecution execution)
    {
    if (entryOrder != null && entryOrder == execution.Order)
    set some variables
    .
    if (exitOrder != null && exitOrder == execution.Order)
    reset some variables
    .
    }


    There is no problem when entry and exit are within a session.
    But, if the entry was made in a prior session, the exitOrder object will never match the execution.Order object, and so the variables are not reset.


    Last edited by Camdo; 01-07-2011, 04:02 PM.

    #2
    Hello Camdo,

    Can you please clarify session here. Do you mean trading session as in you're looking for orders made yesterday?

    Or are you looking for orders made with a prior strategy session. They were placed, strategy was disabled, and then you enabled again?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      In a realtime simulation account, MyStrategy places an equity order, on 1/3/2011 2:00 pm . The market session and day end. Nt is shutdown for the night. The next day and a new market session, NT is started. MyStrategy is enabled. On 1/4/2011 10:00 AM the equity position is sold. MyStrategy then fails because variables are not reset within OnExecution.
      Last edited by Camdo; 01-07-2011, 04:55 PM.

      Comment


        #4
        There is no persistence between strategy sessions. The strategy is run on historical data, and attempts to match the historical orders with actual orders submitted by the strategy.

        A previously generated order is considered to match an active strategy order when the order action, order type, quantity, limit price, and stop price are exactly identical.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          The strategy does not attempt to match entry and exit orders.

          Refering back to the code in post #1,
          the object exitOrder is set equal to SubmitOrder()
          but, "exitOrder == execution.Order" does not equate.

          That is the problem.

          Comment


            #6
            Yes, unfortunately it is generally difficult to match the historical position with the actual execution. If there were any changes in data after a reload or if you are running with COBC = false then these orders will not match.

            You may consider managing the exit portion manually and waiting until your strategy reaches a flat state before starting again.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Once again, the strategy is not trying to match positions.
              The strategy is using the "Unmanaged Approach".
              I want the strategy to submit the order unconditionally.
              All I am trying to do is determine when the order is filled, without using Positions[].
              The OnExecution method is supposed to be the last call in an order fill.
              So I need to know when OnExecution is called for the SubmitOrder.
              What is the correct way to do this?

              Comment


                #8
                OnExecution is called for every change in execution. We have a sample on submitting target and stop loss orders after receiving fill event for the entry order. This is for managed orders but the same principles apply:


                The snippet you posted is following this. For debugging, try something like this to print execution details for all orders that pass through.

                protected override void OnExecution(IExecution execution)
                {
                Print(execution.Order.ToString());
                }
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  protected override void OnExecution(IExecution execution)
                  {
                  Print(execution.Order.ToString());
                  }
                  That was done. There is no printout. The OnExecution method is not being called. OnExecution is bypassed for an exitOrder if the entryOrder was made in a prior session.

                  Also of interest is that the exitOrder is executed correctly (the Position was changed to flat). It did this without using the OnExecution method.

                  Comment


                    #10
                    Camdo,

                    My previous replies are relevant to your issue. There is no persistence between the prior session to the new session.

                    The only way it can pick up a prior order is if the historical order for the strategy matches exactly with the prior, actual run. The entry order needs to be placed historically for OnExecution to read it.

                    The order submission behavior for this is based on account sync and other strategy settings detailed here:
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Ryan
                      Unfortunately your previous replies are not relavant.
                      This problem is a bug in NT which needs to be addressed.

                      Comment


                        #12
                        Thanks - Please sumbit the following and we'll look into on our end here.
                        • Simple strategy that shows the issue. Remove all custom code.
                        • All strategy settings. A screenshot is good for strategy setting you set at runtime. Will also need settings under tools > options > Strategies > NinjaScript tab.
                        • Steps needed to see the issue.
                        • Description of what you expect to see and what you are seeing instead.
                        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
                        656 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        371 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        574 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        579 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X