Peaksearching

Hi guys, I am currently building a radiation detector with a photodiode.

I wanted to make a peaksearch but only for a short amount of time and then print it on my serial monitor and flush it next time I get there.

here is a sample of my code :

rawSignal=analogRead(counterPin);//add counts if the level mesured is higher than the average level + threshold at the beggining
  if (rawSignal>THRH_LVL){
    digitalWrite(signalLedPin,HIGH);
    count++;
    tone(spkrPin, 3000, 10);
    PeakSearch();
    Serial.println(maxValue);

Here is PeakSearch :

void PeakSearch(){
  int i=0;
  int Z=0;
  maxValue=0;
  while (i=0){
    Z++;
    rawSignal=analogRead(counterPin);
    if (rawSignal>=maxValue){
      maxValue=rawSignal;
    }
    if (rawSignal<maxValue){
      i=1;
    }
  }
  if (Z<=1){
    count--;
  }
  lcd.setCursor(0,0);
  lcd.print(Z);
}

I make an average to determine my threshold level...

my problem here is my peak search prints me all the values. (like if I input a sinus, I get all the value >threshold)

That cannot even compile, so cannot possibly run.
Post your actual code.

Also C has different operators for assignment and comparison.
"if"s are best not followed with a semicolon.