Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating time of a future bar

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

    Calculating time of a future bar

    Hi,

    I am calculating the time of a future bar (for reporting purposes) with the following code where lastBarOfPeriod is a percentage of the total number of historical bars

    idx = CurrentBar - lastBarOfPeriod;
    Print("Calculated Time of last bar in period" + Time[idx].ToString());

    This works perfectly but it seems I could have an issue at some point using a negative index. Is there a built in or better way to do this?

    Best Regards,
    Scott

    #2
    Scott, unfortunately I'm not aware of a method for calculating the time of a bar in the future. If you are using time based bars, you could just add the correct amount of time between the current and the future bar to see how far away it is.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin, thanks for getting back to me. The way I did it works just fine, I was wondering if there were a better (less likely to break in the future) way of doing it.

      I thought there might be a function to get the time associated with a given bar, somewhat like the function to get the bar associated with a given time.

      Best Regards,
      Scott

      Comment


        #4
        Scott, there is currently not such a function, but I will pass it on as a suggestion if you want.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Austin, thanks, that would be great but the way I did it works as well.

          Best Regards,
          Scott

          Comment


            #6
            Hi Scott, thanks for your kind suggestion how to improve NinjaTrader even further - we'll track it now under # 851 in our system.

            Have a great day,

            Comment


              #7
              Bertrand, thanks so much.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              639 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              366 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              107 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              569 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              572 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X