Could you please fix the post of your sketch by using the code tags.
I was suggesting to test if the sensor was in the magnets field only when the blade with the magnet passes, or if the magnets field extended to the blades before and after the magnet or further.
Like so, place the sensor where it needs to be near the fan, manually rotate the fan slowly so the blade with the magnet passes, observe on the serial monitor when the sensor enters the magnets field and leaves the magnetic field.
This would let you know if the sensor is changing ONLY when the blade with the magnet passes or if your "stuck" in the magnets field for to much of the rotation.
As dc24 said remove the delay, and you can also simplify your sketch:
// measure magnetic field
int raw = analogRead(A0);
Serial.print("Raw reading: ");
if (raw < 513 || raw >517 )
After testing, remove or comment the serial commands, like dc24 also said.