Need help figuring how to make the following code work On Tick tester?

 

Record Session High  = A current candle closes higher than the previous candles up to 6 bars back.

The following code has been made to count the candlestick record session highs up to 8 and then start drawing objects on each candle to mark the overbought or oversold condition.

But this code only works on the open price test and not on tick test. Its because i don't know a way to count bars on tick test. I know iBarShift can be used  and i also got the idea of using with a static modifier object if(Volume[0]==1) barcount++;    

but i cant get these to count in this code.  


void OnTick()
{
   static int objectBuyCount = 0;  

   int lowest = iLowest(NULL,0,MODE_LOW,lowBars,1);   
   double lowestLow = Low[lowest];

   static int bullBarCount = 1;
  
   static bool enableBullCount = false;   

   static double bullBarClose = Close[1]; 

   static bool lowestCount = true;
      
   static int resetBullCount = 1; 


   // Bull Signal  (EG Price has been bearish, now possible reversal)   
   if(Low[1] > lowestLow)
   {                              
      enableBullCount = true;   
   }
   else
   {
      enableBullCount = false;
      lowestCount = true;
      bullBarCount = 1; // My way of resetting barCount and lowestCount if new lowestLow is found
   }     
     
   if(lowestCount == true && enableBullCount == true && Close[1] > Open[1] && Close[1] > lowestLow)
   {
      bullBarClose = Close[1];        
      lowestCount = false; // Switches of this if statement after one use 
   }                                   // until another lowest low
   
   if(Close[1] > Open[1] && Close[1] > bullBarClose)   
   {
      bullBarClose = Close[1];
      bullBarCount++;   
   }               
   
   // Counts each bar only if its close isnt higher than previous RSH barcount
   if(Close[1] < bullBarClose && Volume[1]==1) resetBullCount++; 
      else resetBullCount = 1;
      
   // Resets RSH count and lowest low object ready for new low search
   if(resetBullCount > 6) 
   {
      bullBarCount = 1;
      lowBars = 1;
   }

   // End Of Bulls RSH
   if(bullBarCount >= 8) 
   {
      double c = Close[0];
      datetime t = iTime(NULL,0,0);                
      string ob_Shorts = "Shorts"+TimeToStr(t);
      
      ObjectCreate(0,ob_Shorts,OBJ_ARROW,0,t,c);  // Makes position of arrow end of candle wick +/- 50pts
      ObjectSetInteger(0,ob_Shorts,OBJPROP_ARROWCODE,174);  
      ObjectSetInteger(0,ob_Shorts,OBJPROP_COLOR,clrBlue);
   } 
}
 
renzbub: if(Volume[0]==1) barcount++;   
Bars is unreliable (a refresh/reconnect can change number of bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
 
WHRoeder:
Bars is unreliable (a refresh/reconnect can change number of bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
Thanks for that improvement. 
Reason: