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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    41 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X