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 sjsj2732, 03-23-2026, 04:31 AM
            0 responses
            69 views
            0 likes
            Last Post sjsj2732  
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            312 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            306 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            146 views
            1 like
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            106 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Working...
            X