Filtering only big changes (Processing)

Quick_questions:
I am getting really ugly signals that just go up and down, but only in small differences, so what I wanted to do is to tell the sketch "only change the value if it is over a +/- 50 threshold"

One option is to smooth the incoming signal. An exponential decaying average is very easy to code and quite effective for things like this. The algorithm is:

smoothed = ((weight * smoothed) + newSample) / (weight + 1);

I'm sure you get the idea.

The other option is to record the current filtered value, and only change it when the new value is sufficiently far from it. For example:

if(abs(filtered - newValue) > threshold)
{
    filtered = newValue;
}