Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intrabar indicator value in BT?

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

    Intrabar indicator value in BT?

    Lets say I run my backtest on a 5 min chart and I added a 1 min TF (Add....).
    Lets say I need a SMA(3) of a 5 min, but I want it intrabar. Is it possible?
    An example:
    I'm on a 10:15 bar, so the SMA(3)[0] = (Closes[0][2] + Closes[0][1] + Closes[0][0])/3
    At 10:16 my strategy is processing 1 min TF (BarsInProgress == 1).
    Now I need the SMA(3)[0] = (Closes[0][1] + Closes[0][0] + Closes[1][0]) / 3.
    This is the value in live trading at 10:16. Correct?
    The same for 10:17, 10:18, 10:19. At 10:20 it should be as at 10:15.

    Is it possible?
    The SMA(3) was just an example that is not an indicator I really need.

    Baruch

    #2
    Hi Baruch, yes this is possible only if you custom calculate the higher timeframe value using the more granular series in your backtest.

    Comment


      #3
      Hi Bertrand,
      Your answer in encouraging, but I don't really understand what you mean.
      Are you saying that I take the relevant values, which I have, and make my own calculation?
      So for example how would I calculate EMA(5)?
      Do I need to reverse engineer the indicator?
      Or I can apply the indicator calculation on my data?
      The DataSeriesObject is almost perfect for doing it. If it could store one more value (next bar) it would work.

      Baruch

      Comment


        #4
        Hi Baruch, easiest would be something along the lines of the attached example, this will be more accurate for anything not using EMA compared to SMA of course but it's still a close approximation. If you would prefer not to go down that route, then you could also work in Market Replay as setting COBC = false would give the desired effect there.
        Attached Files

        Comment


          #5
          Hi Bertrand,
          That much I know, but its not what I asked. I need it in BT.
          So my suggestion is: Make a DataSeries one bar longer than the actual data. The last value will be for the next bar. So on a granular TF the set would be DataSeries.Set(-1,value). On a main TF it will overwrite this value and make it of current bar (0).
          Now if exist value for the next bar the indicator will calculate including it and if there is no value the indicator will calculate without it. You have similar behavior with Reset!

          Baruch

          Comment


            #6
            Baruch, using the 1 min series running a longer indicator as used in my screenshot would be feasible in backtesting as well, of course you would introduce more noise here using a higher granular series as substitute.

            Thanks much for your suggestion, I'll make to forward to product development for consideration (tracked under # 1329).
            Last edited by NinjaTrader_Bertrand; 10-13-2011, 03:31 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            575 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X