Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarDelta calculation- Delta Bar

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

    BarDelta calculation- Delta Bar

    Hi all, i am not sure why when i calculate current bar delta using this code (barsType.Volumes[CurrentBar].BarDelta ) it gives me the correct number but when try to calculate one bar ago using this code (barsType.Volumes[1].BarDelta ) it doesn't give me the correct number? can you please advise?

    #2
    Using '1' for 'one bar ago' is incorrect thinking.

    The BarDelta value on the previous bar is this,

    barsType.Volumes[CurrentBar-1].BarDelta

    The documentation for Volumetric bars clearly states
    that the index being used is not a BarsAgo reference,
    so using an index of '1' is not appropriate here.

    Scroll to the bottom of this page,


    "Please note in the example above a CurrentBar
    reference is used as index, and not a BarsAgo
    reference.​"

    Comment


      #3
      Thank you bltdavid​ for your response. but when i tried the code it gave me the following exception: Error on calling 'OnBarUpdate' method on bar 0: Index was outside the bounds of the array.
      can you please advise?

      Comment


        #4
        Hello yosaam,

        May I confirm you have a condition to confirm that CurrentBar is greater than 1?

        if (CurrentBar < 1)
        return;

        Below is a link to a forum post on indexing errors.
        Hello, I want to create an indicator that show data in a chart but calculate in other charttime different to the time of the chart where is showed. For example:
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you so much Chelsea. it's working now after i added the:
          if (CurrentBar < 1)
          return;​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          548 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X