Code for getting consecutive up and down tick direction

 
int Cur_p = Ask, initi_p = 0,cnt=0;
     
if(Cur_p>initi_p){
     cnt=cnt+1;
     initi_p =Cur_p; }if(Ask<initi_p) cnt=0;

Please any help on why this code is not working.

i need a code to calculate consecutive up tick and down tick to get how fast price is moving in each direction.

 
  1. It's not working because you don't save anything between ticks (init_p and cnt are zero each tick). You would if they were static/global variables.
  2. It's not working because truncating to an int. Prices are doubles.
 
William Roeder:
  1. It's not working because you don't save anything between ticks (init_p and cnt are zero each tick). You would if they were static/global variables.
  2. It's not working because truncating to an int. Prices are doubles.

Please help me with correct code snippet, i have tried changing the int to double and the variable type. Thanks in Advance. 

Reason: