Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to get tick count for a certain range?

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

    how to get tick count for a certain range?

    Hi,

    I'm developing an indicator that needs to get the total number of tick counts within a specific range.

    For example, if I'm loading a daily bar chart for the last 30 days. I need to count how many ticks there are in total in these 30 daily bars.

    I found Bars.TickCount. But it only returns total number of ticks of current bar. Then how do I return total number of ticks within last 30 bars?

    Thank you!

    #2
    Hello HiddenPhilosopher, thanks for your question.

    That would need to be implemented in the indicator e.g.

    Code:
    public class CountTicks : Indicator
        {
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    //...
                }
                else if (State == State.Configure)
                {
                    AddDataSeries(Data.BarsPeriodType.Tick, 1);
                }
            }
    
            int tickCounter = 0;
            protected override void OnBarUpdate()
            {
                if(BarsInProgress == 1)
                {tickCounter++;}
    
                if(BarsInProgress == 0)
                {
                    if(CurrentBars[0] % 30 == 0)
                    {
                        Print(tickCounter);
                        tickCounter = 0;
                    }
                }
    
            }
        }
    That's just one way you could do it. There could be many ways though.

    Please let me know if I can assist any further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    673 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    379 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    111 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    577 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    582 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X