Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Timing of Order execution after bar close

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

    Timing of Order execution after bar close

    Hi,

    I have a strategy that is supposed to calculate the value of an indicator at bar close, and if the criteria is met, submit an order after the bar close. What I'm experiencing though is that the order is being submitted at the end of the second bar, not the beginning of the second bar. E.g. imagine I have 15-min bars and the criteria was met at the close of the bar ending at 8:30am. The order should be submitted at 8:30:01 am, however it seems my orders are consistently being submitted 15 minutes later, at 8:45, which is the end of the second bar.

    What settings do I need to change to avoid this delay?

    On a related note: what's the difference between the "Calculate on Bar Close" settings available in the ninjascript wizard (when creating/editing a ninjascript) vs. the same setting in the new strategy window (when setting up the live strategy for a specific instrument)?

    #2
    Hello mic414,

    Orders that are submitted when a bar is closed will always show on the next bar. This is because the current bar has now closed and the order took place during the next bar. This does not mean that the order is not submitted until the end of the next bar. It just means that the order took place during that next bar.

    To check the time the order was actually submitted or filled you can look at the Log tab of the Control Center for the order. Each state change of the order will have a new line in the log along with a timestamp of when that state changed.

    With this you can see when the order was submitted, accepted, working, and filled.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by mic414 View Post
      Hi,

      I have a strategy that is supposed to calculate the value of an indicator at bar close, and if the criteria is met, submit an order after the bar close. What I'm experiencing though is that the order is being submitted at the end of the second bar, not the beginning of the second bar. E.g. imagine I have 15-min bars and the criteria was met at the close of the bar ending at 8:30am. The order should be submitted at 8:30:01 am, however it seems my orders are consistently being submitted 15 minutes later, at 8:45, which is the end of the second bar.

      What settings do I need to change to avoid this delay?

      On a related note: what's the difference between the "Calculate on Bar Close" settings available in the ninjascript wizard (when creating/editing a ninjascript) vs. the same setting in the new strategy window (when setting up the live strategy for a specific instrument)?
      Is this live or in the Strategy Analyzer?

      Comment


        #4
        Yes, I expect that the trade will show up on the second bar in the chart. That's not the problem. The problem is that the trade doesn't execute until the end of the second bar. I checked the actual execution time in IB TWS, and orders from Ninjatrader are submitted one bar later than it should be. (In the example above, 15 minutes later).

        Comment


          #5
          Originally posted by koganam View Post
          Is this live or in the Strategy Analyzer?
          It is live trade executed by the strategy through IB.

          Comment


            #6
            Sorry, one more detail to add, which might be important: my data series is plotted in Linebreak mode, e.g. 15 min Linebreak.

            Comment


              #7
              Hi mic414,

              To further understand what is happening could you add a print to your code and then supply me your log and trace after allowing the strategy to make a few live orders.

              The print should just be the current time. Place this exactly one line before each line of code that is an order command.

              Print(DateTime.Now());
              EnterLong(1, "long1");


              Then open the Output window (Tools -> Output Window...) and then start your strategy.

              After the strategy places a live order this should print the time of the live order to the Output window.

              Please send the output of the time stamp of the live order along with your log and trace files to support[at]ninjatrader[dot]com. (Do not post these or any other personal information to the forum)

              You will find your NinjaTrader trace file in the following directory:
              • (My) Documents\NinjaTrader 7\trace\trace.20131119.txt


              You will find your NinjaTrader log file in the following directory:
              • (My) Documents\NinjaTrader 7\log\log.20131119.txt


              In the body of email please write Attn: Chelsea #956211. Also please include a link to this forum thread.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi,

                I found the root cause, not sure if it's a bug or by design somehow. I had two datasources configured: Kinetick as the primary source, and IB as secondary and for trading. Additionally, the strategy was running on linebreak chart, which might have some relevance as bar creation in a linbreak chart is more complicated. Anyhow, with this configuration, all my orders were getting submitted around 15 minutes later, with 15 minutes being the base period for the linebreak chart.

                This morning I connected to IB only and all order are executed as expected, right after the close of the bar that generated the signal.

                Comment


                  #9
                  Hello mic414,

                  With Kinetick connected first as the primary data feed your orders should still be submitted when OnBarUpdate is run at the end of the bar.

                  To look into this I will still need to see the print and compare this with your log file.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by FrazMann, Today, 11:21 AM
                  2 responses
                  6 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Started by rjbtrade1, 11-30-2023, 04:38 PM
                  2 responses
                  80 views
                  0 likes
                  Last Post DavidHP
                  by DavidHP
                   
                  Started by Spiderbird, Today, 12:15 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Started by lorem, Yesterday, 09:18 AM
                  5 responses
                  18 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by cmtjoancolmenero, Yesterday, 03:58 PM
                  12 responses
                  42 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X