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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    49 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    69 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    36 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    96 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    59 views
    0 likes
    Last Post PaulMohn  
    Working...
    X