Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Backtesting and orders execution timezone

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

    Backtesting and orders execution timezone

    Hello,

    I have issues finding why my strategy doesn't execute orders during certain times.

    NT is set to UTC-6 currently, I am testing NQ. The times on the chars are correct, the execution times are correct as well (as written in the anayzer window) but trades that are after 17:00 my local time (this being 9am CME time) are not executed. I can see while debugging that a call is send to EnterShortLimit/EnterLongLimit but there is no execution.

    I have changed my PC settings as well, redownloaded the historical data but nothing. I can see while debugging correct timestamps, the orders are sent for execution but are not executed.

    I am missing something, any help is appreciated.

    Below is a screenshot, the arrow shows where the trade should have happened and I saw it sent to EnterShortLimit. However the timestamp is 9am CME which is 1700 my local time and there is no execution

    Click image for larger version

Name:	image.png
Views:	100
Size:	7.1 KB
ID:	1249896

    #2
    If you right click on the chart and pull up the strategy performance report and go to the orders section, do you see your order and was it canceled or rejected?
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Originally posted by QuantKey_Bruce View Post
      If you right click on the chart and pull up the strategy performance report and go to the orders section, do you see your order and was it canceled or rejected?
      I see cancelled
      Click image for larger version

Name:	image.png
Views:	61
Size:	6.5 KB
ID:	1249910
      Also playing around now I realised that if I use EnterShort/EnterLong I have orders executing at those times but limit orders don't work

      Comment


        #4
        If a limit order doesn't work at the position of the arrow you are trying to enter at a price that is not reached. Limit orders only execute if price retraces back to your limit price, and it sounds like in your case it does not. It might look visually like it does but if you are placing the order intrabar, you may not realize that the bar where it was placed, while price was there, it was there earlier than when you placed it. If you want to be certain of an entry, use a market order, or if you choose to use a limit order to get a better fill price, understand that you will not always get in.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Originally posted by QuantKey_Bruce View Post
          If a limit order doesn't work at the position of the arrow you are trying to enter at a price that is not reached. Limit orders only execute if price retraces back to your limit price, and it sounds like in your case it does not. It might look visually like it does but if you are placing the order intrabar, you may not realize that the bar where it was placed, while price was there, it was there earlier than when you placed it. If you want to be certain of an entry, use a market order, or if you choose to use a limit order to get a better fill price, understand that you will not always get in.
          But price did retrace to my limit price. And this happens every day of the backtested period. I just showed a clear example

          Comment


            #6
            We don't have enough information to interpret from the screenshot if the limit order would have been filled from your drawing. Is Calculate set to Calculate.OnBarClose or something else? If it's OnEachTick or OnPriceChange are you repeating the entry order each time? If not and these are managed orders, it would be canceled on the next tick intrabar. If it's OnBarClose you should consider adding a Draw.ArrowDown there on the chart at the same bar where you place the order, and put the arrow at the right bar number and at the order price so you can see this more clearly. If you are not using the simple managed order entry methods are they DAY or GTC? DAY orders would be canceled at the end of the session, which depending on your trading hours, could be a concern.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #7
              Originally posted by QuantKey_Bruce View Post
              We don't have enough information to interpret from the screenshot if the limit order would have been filled from your drawing. Is Calculate set to Calculate.OnBarClose or something else? If it's OnEachTick or OnPriceChange are you repeating the entry order each time? If not and these are managed orders, it would be canceled on the next tick intrabar. If it's OnBarClose you should consider adding a Draw.ArrowDown there on the chart at the same bar where you place the order, and put the arrow at the right bar number and at the order price so you can see this more clearly. If you are not using the simple managed order entry methods are they DAY or GTC? DAY orders would be canceled at the end of the session, which depending on your trading hours, could be a concern.
              Thank you for the answer.
              I use OnBarClose.
              The rectangle on my chart indicates the candle the validates my setup, so at that candle I have a limit order set.
              I tried DAY and GTC orders (GTC being default). This exactly is my concern - the orders get cancelled after 17:00 my local time, despite that being 9am CME time.

              Comment


                #8
                Okay, but if you don't repeat the limit order on the next bar, the following bar from your rectangle never comes back to that price, so it would not fill and would cancel at the end of the bar, and on the subsequent bars that do come back to that price, if you are not repeating the order, how would it fill there? If these are managed orders, you need to specify whether you are repeating the order each subsequent bar. If you are not, that is the answer - you're not asking for the order again so it is canceled at the end of the next bar.
                Bruce DeVault
                QuantKey Trading Vendor Services
                NinjaTrader Ecosystem Vendor - QuantKey

                Comment


                  #9
                  Originally posted by QuantKey_Bruce View Post
                  Okay, but if you don't repeat the limit order on the next bar, the following bar from your rectangle never comes back to that price, so it would not fill and would cancel at the end of the bar, and on the subsequent bars that do come back to that price, if you are not repeating the order, how would it fill there? If these are managed orders, you need to specify whether you are repeating the order each subsequent bar. If you are not, that is the answer - you're not asking for the order again so it is canceled at the end of the next bar.
                  Oh I see now, I didn't know the orders actually expire on the next bar. Thank you, will dig in the documentation to find out more about this.

                  Thanks

                  Comment


                    #10
                    Originally posted by QuantKey_Bruce View Post
                    Okay, but if you don't repeat the limit order on the next bar, the following bar from your rectangle never comes back to that price, so it would not fill and would cancel at the end of the bar, and on the subsequent bars that do come back to that price, if you are not repeating the order, how would it fill there? If these are managed orders, you need to specify whether you are repeating the order each subsequent bar. If you are not, that is the answer - you're not asking for the order again so it is canceled at the end of the next bar.
                    Perfect, thank you so much!
                    isLiveUntilCancelled did the trick!

                    Comment


                      #11
                      You're welcome.
                      Bruce DeVault
                      QuantKey Trading Vendor Services
                      NinjaTrader Ecosystem Vendor - QuantKey

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by lightsun47, Today, 03:51 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post lightsun47  
                      Started by 00nevest, Today, 02:27 PM
                      1 response
                      9 views
                      0 likes
                      Last Post 00nevest  
                      Started by futtrader, 04-21-2024, 01:50 AM
                      4 responses
                      45 views
                      0 likes
                      Last Post futtrader  
                      Started by Option Whisperer, Today, 09:55 AM
                      1 response
                      14 views
                      0 likes
                      Last Post bltdavid  
                      Started by port119, Today, 02:43 PM
                      0 responses
                      9 views
                      0 likes
                      Last Post port119
                      by port119
                       
                      Working...
                      X