Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Function/Method to get "Bars to Load" value?

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

    Function/Method to get "Bars to Load" value?

    Hi, is there a function / method to get the "Bars to Load" value that is specified in the "Data Series" settings?

    I would like to use this value to know how many bars would be loaded, so that my indicator only starts to analyse the conditions to draw an object on the chart after X number of bars. For performance reasons, I would not want to start analysing and drawing from the first bar, especially when I have a lot of historical data loaded. For example, I only want to start drawing from the past 1000 bars onwards, while I may have 20,000 historical bars loaded.

    Thanks.

    #2
    Hi nightlights, thanks for posting.

    The BarsArray[] array contains all Bars objects and the count of BarsArray[0] is:

    Code:
    //In OnStateChanged():
    else if (State == State.DataLoaded)
    {
        if(BarsArray[0] != null)
        {
            Print(BarsArray[0].Count);
        }
    }
    Kind regards,
    -ChrisL

    Comment


      #3
      Alternatively, how can I reference/compare the date of the chart to start to run my logic and draw only from 5 days ago?

      Besides these methods which I can think of, what is the best way to limit the number of objects being drawn by an indicator (so that performance is not impacted)?

      Thanks.

      Comment


        #4
        Hi nightlights, thanks for your reply.

        You must use the Time[] array which is an array full of DateTime objects that represent the time stamp of each bar e.g.

        Code:
        if(DateTime.Compare(Time[0], DateTime.Now.AddDays(-5)) < 0)
        {
            Print("Dont Draw");
            return;
        }
        else
        {
            Print("Drawing");
        }
        Another fast way to draw custom graphics is to use SharpDX in the OnRender method, see here for documentation on this subject:



        Kind regards,
        -ChrisL

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        597 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        555 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X