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

Incorrect prices in intrabar backtest entries.

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

    Incorrect prices in intrabar backtest entries.

    In reference to this thread: http://www.ninjatrader.com/support/f...entry+bar+late

    I'm really bummed out by this, because it seems I can't do something that should be very simple. For example, I have a set of conditions that, at some point INTRABAR, become true. The associated strategy action for this set of conditions is, let's say, ENTERLONG. For a concrete example: last price is 2 ticks above prior bar ENTERLONG. In real life trading, you would enter 2 ticks above prior bar high + any slippage. But, near as I can tell, when backtesting in Ninja, no matter what, the actual entry is at the open of the NEXT bar (at least in backtest context).

    If this is so, it makes NT impossible to use for many (if not most) practical backtesting uses where intrabar conditions are met.

    If I'm totally off base here, can anyone explain then how to get a backtest to properly show an intrabar entry?

    Thanks much.

    #2
    coolmoss, the granularity per default you would have access to is the OHLCV data of the primary series used. To simulate getting filled intrabar, you could submit to a finer series as explained here in our sample for this topic -

    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


    However this would not be possible for the wizard created strategies unfortunately unless you unlocked the code and custom coded.

    We have this on our list for future consideration to further enhance and simplify.

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thank you for a clear, understandable answer. I'm disappointed, but hopefully can still figure out something.

      Comment


        #4
        You are welcome - an easier approach would be working for example in Market Replay with the original strategy and using CalculateOnBarClose = false - in this setup the intrabar formation would be present.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          How to implement entry based on second faster data series

          Hi Bertrand,

          I just studied the strategy example you posted above. This might actually work for me, but I'm having a hard time wrapping my head around how to do this:

          Let's say primary series is a Range bar and I have some entry condition that is true at the close of this bar.

          Then, I want to enter X ticks above that range bar. So I could add a second data series, I'm thinking a 1 tick data series. But then from there, it's not clear how I would a) reference the low of the Range bar that just completed (the primary series bar) and then relate that to the secondary series moving X ticks.

          Hope that makes sense.

          Comment


            #6
            Could I do this:

            Conditions met on primary bar series and action would be to set a user variable to X ticks below close. Then on the faster, secondary bar series (I would use 1 tick) I would ENTERSHORT if last price < userVariable?

            If this could work, and if it's not asking to much, could you please show how that would be done in code. This aspect of NT is totally new to me.

            Thanks.

            Comment


              #7
              Hello coolmoss,
              Thanks for writing in and I am replying for Bertrand.

              If you are submitting an buy limit order and want to set the limit price 5 ticks below the low of the Range bar (which is your primary data series) then please use the following code

              Code:
              if (entry condition)
              {
              	EnterLongLimit(Low[0][0] - 5 * TickSize);
              }


              Also in a multi-series strategy you might want to filer the bar series via the BarsInProgress property http://www.ninjatrader.com/support/h...inprogress.htm

              Please let me know if I can assist you any further.
              JoydeepNinjaTrader Customer Service

              Comment


                #8
                Thank you Joydeep,

                I understand the concept, but feeling overwhelmed by the myriad of details. So I have a couple questions as followup:

                1) in your code above, how do I distingquish the fact that the entry condition is on the primary data series and the trade execution is on the secondary series?

                I guess that's really my only question: how to understand what code is processed by which series at what time. I'm studying the NT user guide on multi-bars and barsInProgress but my head feels like it's going to explode and splatter over my freshly painted walls

                Comment


                  #9
                  Hello coolmoss,
                  A code to submit an order to the secondary series while checking for the condition on the primary series will be
                  Code:
                  if (BarsInProgress == 0)
                  {
                  	EnterLongLimit(1, true, 1, Lows[0][0] - 5 * TickSize, "Buy");
                  }
                  Please refer to EnterLongLimit overload
                  Code:
                   EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)
                  via which you submit your order to the secondary data series.


                  Please go through the multi-series help guide to get a through concept on it.


                  Please let me know if I can assist you any further.
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #10
                    Joydeep (or whoever replies) this was very helpful. I'm Studying the Multi-time frame tutorial and this question arises:

                    All the examples seem to use periodicities which mesh together nicely (eg. 1 min goes into 3 minutes). If, as in the case of my needs, the primary data series is a Range bar and I'll be using a tick bar for the secondary series.

                    Will this work?

                    Comment


                      #11
                      Hello coolmoss,
                      Yes it will work.

                      You can have a range bar as your primary series and a tick bar as your secondary data series.

                      Please let me know if I can assist you any further.
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #12
                        Cool! What started out as a big problem looks like it has lead to me learning a lot and producing some new ideas on how to do my system which could be much better than the prior approach I was taking.

                        Thanks

                        Comment


                          #13
                          Hello coolmoss,
                          Glad to know you are getting the concepts right.

                          Please let me know if I can assist you any further.
                          JoydeepNinjaTrader Customer Service

                          Comment


                            #14
                            The multi time frame is good if smaller time frame data is available but what if it's not? Is there any way to enter IntraBar without using the multi time frame and make it back testable in strategy analyzer?
                            Last edited by bogey20; 03-12-2013, 07:38 PM.

                            Comment


                              #15
                              bogey20, unfortunately not in backtesting - you would need finer data here to simulate this. For replay and live testing of course this would be different.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cupir2, Today, 07:44 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post cupir2
                              by cupir2
                               
                              Started by reynoldsn, Today, 07:23 AM
                              6 responses
                              19 views
                              1 like
                              Last Post reynoldsn  
                              Started by reynoldsn, Today, 07:26 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post reynoldsn  
                              Started by ETFVoyageur, 05-07-2024, 07:05 PM
                              12 responses
                              79 views
                              0 likes
                              Last Post bltdavid  
                              Started by Haiasi, 04-25-2024, 06:53 PM
                              5 responses
                              76 views
                              0 likes
                              Last Post alancurry  
                              Working...
                              X