Petra on Programming: Get Rid of Noise

A major problem of indicator-based strategies is that most indicators produce more or less noisy output, resulting in false signals. The faster the indicator reacts on market situations, the noisier is it usually. In the S&C December issue, John Ehlers proposed a de-noising technology based on correlation. Compared with a lowpass filter, this method does not delay the signal. As an example, we will apply the noise elimination to Ehlers’ MyRSI indicator, a RSI variant that he presented in an earlier article.

The MyRSI indicator sums up positive and negative changes in a data series, and returns their normalized difference. The C version for Zorro:

var MyRSI(vars Data,int Period)
{
var CU = SumUp(Data,Period+1);
var CD = -SumDn(Data,Period+1);
return ifelse(CU+CD != 0,(CU-CD)/(CU+CD),0);
}

For eliminating noise, the function below (NET = Noise Elimination Technology) calculates the Kendall Correlation of a data series with a rising slope. This is supposed to remove all components that are not following the main trend of the indicator output. The code:

var NET(vars Data,int Period)
{
int i,k;
var Num = 0;
for(i=1; i<Period; i++)
for(k=0; k<i; k++)
Num -= sign(Data[i]-Data[k]);
var Denom = .5*Period*(Period-1);
return Num/Denom;
}

For making the effect of the denoising visible, we produce a SPY chart from 2019-2020. The red line is the original MyRSI, the blue line the de-noised version:

The technology appears to work well in this example for removing the noise. But the NET function is not meant as a replacement of a lowpass or smoothing filter: its output is always in the -1 .. +1 range, so it can be used for de-noising oscillators, but not, for instance, to generate a smoothed version of the price curve.

One might be tempted to use the blue line in the above chart for trade signals. RSI-based signals usually trigger a long trade when the indicator crosses below a lower threshold, and a short trade when it crosses above an upper threshold. But alas, neither is strategy development this easy nor is the de-noised MyRSI the holy grail of indicators. I tested several methods to use it for generating SPY trade signals, but neither was a strong improvement over a simple lowpass filter strategy or even to buy-and-hold. Maybe a reader can find a more convincing solution?

The MyRSI and NET functions and the script for generating the chart can be downloaded from the 2020 script repository. You need Zorro 2.33 or above.

2 thoughts on “Petra on Programming: Get Rid of Noise”

  1. Well… Managed to bump up algo by AR 5% using this. Not sure if that’s worth it. Probably there’s a better application of it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.