Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about Bars.TickCount

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

    Question about Bars.TickCount

    Hi,

    I am trying to obtain a measure of the price movement in ticks. And if I use Bars.TickCount, like:

    Draw.TextFixed(this, "Info", "\nNo of ticks: "+Bars.TickCount, TextPosition.TopRight);

    I see that the result with TickCount is really a value that is much higher that the real price movement in ticks. In the following video you can see this. Bars.TickCount increases very quick up to 28 when the real tick-movement of the price is 5-6 ticks.



    So, my question is: Is there any method to obtain the real price movement in ticks?

    Thanks,

    #2
    Hello,

    Thank you for the question.

    The Bars.TickCount would be the total number of ticks of the current bar processing rather than a number of ticks in movement. To get the amount of ticks of price movement, this is something you would need to calculate.

    You could likely store the price of when a bar starts and then subtract the current price to get a difference. The difference you could convert to an amount of Ticks to find the difference in Ticks.

    Here is one example, this assumes the script is running OnEachTick:

    Code:
    private double storedPrice;
    protected override void OnBarUpdate()
    {
    	if(IsFirstTickOfBar)
    	{
    		storedPrice = Close[0];
    	}
    	double ticks = Math.Ceiling((Close[0] - storedPrice) / TickSize );
    	Draw.TextFixed(this, "Info", "\nNo of ticks: "+ticks, TextPosition.TopRight);
    }




    I look forward to being of further assistance.

    Comment


      #3
      This is clear, thanks. But I need to count the number of changes in ticks regardless the direcction of the movement. I mean, imagine that in your example No of ticks have the following values:
      0,1,2,1,0,0,0,0,0,0,-1,-2,-1,0,0,0, so I need to have a counter that tell me the number of changes, in this case: 15 that corresponds with the movement in ticks (the Sum of all ticks movement). I don't know if I have explain me well?.

      I tried to use a conter (int counter) and a boolean (bool changetick), like this:

      TickArray[i]= Math.Ceiling((Close[0] - storedPrice) / TickSize );

      if(i>0)
      {
      if(TickArray[i]!=TickArray[i-1] && !changeTick) {j++; changeTick=true;}
      else changeTick=false;
      }

      if(i>1) Draw.TextFixed(this, "Info", "\n\nMovimiento Ticks: "+j, TextPosition.TopRight);
      i++;

      But the result is not accurate, see the following video to check:



      The counter = 7 but the real times of ticks movement is 10.

      Thanks,

      Comment


        #4
        Hello,

        Thank you for the reply.

        If you are trying to detect when there was a change, you would likely need to store the prior ticks value and then check if the new value is different. If so, increment your counter.

        perhaps something like the following would work for what you are trying?
        Code:
        private int lastTickValue = -1;
        
        if(lastTickValue != Math.Ceiling((Close[0] - storedPrice) / TickSize ))
        {
            i++;
            lastTickValue = Math.Ceiling((Close[0] - storedPrice) / TickSize );
        }

        I look forward to being of further assistance.

        Comment


          #5
          If I wish to find out the number of ticks (trades) in the current bar I can use Bars.TickCount. Can this be used with an index to find out the number of ticks in the previous bar such as Bars.TickCount[1] etc?

          Comment


            #6
            Hello,

            Thank you for the post.

            There is no historical collection of tick counts, so this would be something you need to store yourself or do with your own logic. You could look into using a Series<int> to store each bars Tick Count if it is needed later:



            I look forward to being of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            663 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            376 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            110 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            580 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X