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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    82 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    154 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    101 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    289 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X