Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entrance Question

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

    Entrance Question

    I notice that when conditions are met for an entrance condition that the order is not actually placed till the 2nd bar after the condition was met. Why is this? Is there a way to control what bar, "Current" or "Next" that the order is placed at?

    #2
    neb1998, the backtester evaluates conditions on a bar-by-bar basis. Say, for example, a 10 SMA line crosses above a 15 SMA line on the 9:03am one minute bar. On the next OnBarUpdate() that crossover would be recognized and the order would fire at the 9:04 bar. This order is not filled on the current bar, but on the next bar because the open of the next bar (9:05) is the first place an action could occur.

    If you would like to backtest with more resolution, please see this page.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. So if the entry conditions for an order are met between a 10:00 and 10:15 min bar and i use the sample you provided with a granular resolution of 1 min and 15 min for my actual entry order chart NT will allow entry on the 10:15 min bar?

      So far i have not been able to get this to work, but working on it.

      One thing i notice is that the last Periodtype that is added within the Initialize method also is the time period that onbarupdate method updates at. Is this on purpose? I worked with print statements to verify this.

      To clarify further. 15 min RT chart. Trading on 15 min bars but have a 1 min periodtype setup. That should allow me to enter the market between 10:00 and 1015, so if the conditions are met at 10:07 the order will show up on the next 15 min bar = 1015 min.

      Thanks for any help, i have spent a lot of time on this...the timing is extremely critical.

      Comment


        #4
        More Info

        I have posted a picture here as well to show the problem. I have a cross condition for entry:

        Yet the short does not take place till the following 2nd bar. I need to enter on the first bar after the condition is met.

        These are 15 minute bars.

        I have tried the Intrabarbacktest sample and it does not work, .This is the actual code running from that file with no changes.

        Typically with the cross condition being evaluated on a maximum time increment of 1 min i should be able to fire an order entry well before the first red bar on that chart so the order is filled on the first chart.

        Help?
        Attached Files

        Comment


          #5
          The crossover in the chart on message #4, between the 8th & 9th bar, doesnt exist until AFTER the 9th bar is formed ... assumed COBC=true, or historical backtesting (which is always COBC=true in NT)... so the earliest trade can be entered is open of the 10th bar.

          Hope this helps,
          TJ

          Comment


            #6
            This doesnt seem good. So it appears there is actuall no working LIB function for backtesting within NT?

            Comment


              #7
              Neb, can you please clarify? What is a LIB function?
              AustinNinjaTrader Customer Service

              Comment


                #8
                look inside bar

                Allowstrades to execute between say two fifteen min bars if on a. 1min bar the entry conditions is true

                Comment


                  #9
                  neb, this is definitely possible. I just took the sample I linked to you in post #2, modified it a bit to use the data from the primary bars, and got the expected results.

                  I've attached my strategy and two screenshots. The first is the chart - the MAs are not crossed at the 10:15am bar, but they are at 10:20am. Since the crossover occured on the 10:20 bar, the order was sent to the very next place a trade could occur, the one minute series. As you can see in the next screenshot, the trade did indeed fire at 10:21am, not 10:25am as indicated on the chart.
                  Attached Files
                  AustinNinjaTrader Customer Service

                  Comment


                    #10
                    Ok thanks, just so i understand this. For backtesting Calc on bar close is always true?

                    So in real time testing i would expect that same order to be placed between the 1015 and 1020 bar? (with Calc on bar close = off), meaning i am evaluating the code tick by tick. which could possibly cause the cross to occur before the 1020 bar is completed. Is this correct?

                    Thanks a lot for your help, all our strategies are multitime frame and for some reason they are backtesting much differently from MC, so i am trying to ensure i am clear on this.

                    Ben

                    Comment


                      #11
                      Hello,

                      Yes you are understanding correctly on the backtest is always run in Calculate On Bar Close = True mode.

                      There is a way to backtest however with a better Granularity and that constitutes feeding in tick data. The backtest will still run withCOBC = true mode. However you give it much more points to run off of. For example, adding in a 1 tick chart to a strategy will add as fine of granularity you can add to the backtest.

                      You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


                      Let me know if I can be of further assistance.
                      BrettNinjaTrader Product Management

                      Comment

                      Latest Posts

                      Collapse

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