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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          267 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          169 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          171 views
          1 like
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          260 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          210 views
          0 likes
          Last Post CarlTrading  
          Working...
          X