Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mixing bar series in backtesting

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

    Mixing bar series in backtesting

    I'm looking to find out if the following is possible:

    1) My strategy and indicators use 2 bar series: 1000 volume (primary bars) and 1 tick secondary bars.

    An easy example of the usage is a percent change calc where the numerator is the secondary "real-time" series and the denominator is the slower 1000 volume series. So, change = 1 tick (secondary) / 1000 volume (primary) - 1

    The objective is to be able to enter a position the instant the 'change' indicator hits a threshold value at a 1-tick granularity

    2) This strategy runs as expected in real time with COBC = false. However, in backtest mode the strategy and indicator only update on the primary bars.

    3) My question, at this point is not "how to?". I'd like to know "is it POSSIBLE?"
    --In other words, let's assume I've used the full force of NinjaScript, including COBC, FirstTickOfBar, BIP, BarsArray, etc,, etc., IS IT POSSIBLE to backtest using 1-tick secondary bars AND 1000-volume primary bars AND get intrabar (primary) indicator value updates AND intrabar execution?

    #2
    Hello bluelou,

    Thanks for your note.

    The issue you are running into is that Calculate on bar close is ALWAYS true when backtesting or with historical data on a chart.

    Below is a link to the help guide on CalculateOnBarClose that mentions this in the first sentence.
    http://www.ninjatrader.com/support/h...onbarclose.htm

    To get around this, you will need to do all of your processing on the 1 tick series. Since FirstTickOfBar does not work in backtesting due to CalculateOnBarClose being true, you will need a counter to track the number of bars that have passed since the last close of the 1000 volume series. Reset this counter in OnBarUpdate when the 1000 volume series is the current BarsInProgress.

    To answer questions 1 and 2, yes this is possible.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ChelseaB,
      Let's see if we can narrow this down a bit further.
      1) I understand that COBC = true in backtesting. My key question was question #3. You answered #1 and #2. Is #3 possible as well?

      2) When you said "To get around this, you will need to do all of your processing on the 1 tick series." what exactly does that mean?
      --Is it still possible to have 1-tick as secondary and 1000-volume as primary? I'd like to maintain this order and perhaps do "all...processing" on the 1-tick secondary series through the careful use of BIP and/or BarsArray. Would that work?



      Originally posted by NinjaTrader_ChelseaB View Post
      To get around this, you will need to do all of your processing on the 1 tick series.

      To answer questions 1 and 2, yes this is possible.

      Comment


        #4
        Hello bluelou,

        The answer to number #3 was the main text of my reply.

        The issue you are running into is that Calculate on bar close is ALWAYS true when backtesting or with historical data on a chart.

        Below is a link to the help guide on CalculateOnBarClose that mentions this in the first sentence.


        To get around this, you will need to do all of your processing on the 1 tick series. Since FirstTickOfBar does not work in backtesting due to CalculateOnBarClose being true, you will need a counter to track the number of bars that have passed since the last close of the 1000 volume series. Reset this counter in OnBarUpdate when the 1000 volume series is the current BarsInProgress.
        I am saying what you are suggesting. You will need to do all of your processing on the 1 tick series by only processing when it is that BarsInProgress. You will be able to use BarsArray to find the data from the other data series.

        Yes, you can have your tick series be secondary and your 1000 volume be primary. This is how it should be structured.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          ChelseaB,
          Thanks for the clarification. I wanted to make sure that I could do this w/BIP and BarsArray. I wanted to confirm that it wasn't REQUIRED that the higher frequency bar had to be the primary bar.

          In other words, it is BIP that determines which bar series is being processed, not whether one series is called primary and another secondary, right?

          Comment


            #6
            Hi bluelou,

            That is correct.

            Which ever instrument is loaded into the backtest or on the chart will be the primary dataseries and will be BarsInProgress 0 and BarsArray[0]. The added series will be the secondary series and will be BarsInProgress 1 and BarsArray[1].

            The BarsInProgress will control processing done on the particular desired series.

            If you want to use 1000 volume as the primary and the 1 tick as the added secondary, then do your processing on BarsInProgress 1 and reference the 1000 volume data as BarsArray[1].

            Below is a link to the help guide on BarsInProgress.
            http://www.ninjatrader.com/support/h...inprogress.htm

            Also, here is a link to BarsArray.
            http://www.ninjatrader.com/support/h.../barsarray.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              ChelseaB,
              Thanks again for the confirmation.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, Yesterday, 06:40 PM
              2 responses
              19 views
              0 likes
              Last Post algospoke  
              Started by ghoul, Today, 06:02 PM
              3 responses
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              45 views
              0 likes
              Last Post jeronymite  
              Started by Barry Milan, Yesterday, 10:35 PM
              7 responses
              20 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by AttiM, 02-14-2024, 05:20 PM
              10 responses
              181 views
              0 likes
              Last Post jeronymite  
              Working...
              X