Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to determine number of bars back for a given time in the past

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

    How to determine number of bars back for a given time in the past

    Hi..

    If I use a non-time based bars like Volume or Range bars, how can I determine how many bars ago a certain time was? For example, if the current time is 5:07am, and I am trying to determine how many bars ago was 1:00am, I know I could loop through Time[n] where n starts with 1 and increments by 1 until I reach or pass before 1am, but I didn't know if their was a built in function that already does this. Is there a built in function for this? Something like n = BarsAgoFromTime("1:00am"); Or is using Time[n] loop the only way?

    Thanks in advance,
    Tom

    #2
    Hello Tom, and thank you for your question. This situation is what the GetBar() method was designed for. I am posting an excerpt from the help guide.

    Originally posted by http://ninjatrader.com/support/helpGuides/nt8/en-us/getbar.htm
    // Calculate the bars ago value for the 9 AM bar for the current day
    int barsAgo = CurrentBar - Bars.GetBar(new DateTime(2015,10,22,10,21,
    59));
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Perfect Jessica! Thanks!

      I tried finding in the HTML Help online, but I could not find this. Do you have a PDF version of the Help Guide? Or even better Win Help version? The HTML version is not easy to search.

      Any suggestion on good third party programming guides or books for NT8?

      Thanks again.. tom

      Comment


        #4
        While I can not advise on programming and developing books for NT8, we have a PDF version of the help guide behind this link



        Please let us know if there are any other ways we can help.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        50 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X