Your arithmetic seems flawed. As written, you would allow a jump from 10000 to -10000 as okay. Instead, you want to use abs() only once.
difference = abs(newvalue - lastvalue);
You can also avoid abs() altogether.
difference = newvalue - lastvalue;
if (difference < 0) difference *= -1;
if (difference < SPIKE) currentvalue = newvalue;
or
difference = newvalue - lastvalue;
if (difference > -1*(SPIKE) && difference < SPIKE) currentvalue = newvalue;
These might all be similarly efficient. If there is any difference, the last one might be best because the multiplication occurs in the compiler. I leave it to you to test for yourself.