Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetBar() performance

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

    GetBar() performance

    I wanted to use GetBar() in an indicator that I am working on, and was wondering if this is an efficient function (i.e. is is using a binary serach to find the bar) as I might be calling it frequently?

    #2
    I do not use this method. Instead of searching for a timestamp in the past I prefer to store the desired value/values when they are processed in OnBarUpdate().

    Regards
    Ralph

    Comment


      #3
      Hello,

      I am sorry, you will need to test GetBar() and determine its efficiency. I do not know.
      DenNinjaTrader Customer Service

      Comment


        #4
        Originally posted by Ralph View Post
        I do not use this method. Instead of searching for a timestamp in the past I prefer to store the desired value/values when they are processed in OnBarUpdate().
        Yes, I generally do this as well, but sometimes you don't know what you need until you know what you need.

        Comment


          #5
          Ok, I ran a quick test over 40000 bars, comparing GetBar(), a simple binary search, and a simple linear search. Granted, my methods are a little rough, but thankfully the results show that GetBar is not a linear search. The results also showed that a simple binary search would be upto 6X faster depending what you are looking for (always looked at indexes that were worst case for bin search). That being said, I think the Ninja version is adequate, but I will write my own version to maximize perf.

          Comment


            #6
            Originally posted by aslane View Post
            ...sometimes you don't know what you need until you know what you need.
            That happens to me frequently.

            And GetBar() requires an DataTime object as parameter. These instantiations are expensive operations.

            Regards
            Ralph

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            612 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            355 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            561 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            564 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X