
Trading efficiency largely depends on the methods of analyzing market data. One such method is orthogonal polynomials. These polynomials are mathematical functions that can be used to solve a number of problems related to trading.
The most famous orthogonal polynomials are the Legendre, Chebyshev, Laguerre and Hermite polynomials. Each of these polynomials has unique properties that allow them to be used to solve different problems. Here are some of the main ways to use them:
Let’s see how orthogonal polynomials can be applied in practice.
The whole point of technical analysis comes down to identifying patterns in price movements. But financial time series typically contain noise that obscures these patterns. Let’s see how orthogonal polynomials can be applied in a market setting.
The basic idea is that these polynomials can be used to decompose complex signals into simpler components. This decomposition allows us to sort out noise and identify trends.
As an example, I will use Legendre polynomials to make a smoothing indicator based on them. The general equation of these polynomials and their definition domain are given by the following expressions:
I will use polynomials up to the 9th degree. This is quite sufficient for smoothing, and using higher degree polynomials can add noise and hide the main trends in price movement. The polynomial equations used here are given in the table.
First of all, I need to convert the price indices into the domain of these polynomials. To do this, I apply the shift function for each i index:
After that, I calculate the values of all the polynomials I am interested in for each value of x[i]. For example, I will calculate the value of a 2nd degree polynomial with the period of 3:
Now I need to introduce a correction for discreteness. The sum of the values of a polynomial of degrees 1 and higher should be equal to zero. To fulfill this condition, I need to calculate the correction:
With this correction, I adjust the values of the polynomial:
Now the most interesting part begins. Any time series can be decomposed into a sum of polynomials taken with a certain weight:
The weights themselves can be calculated as follows:
It looks strange and a little scary. In fact, everything is simple. Let’s take a polynomial of degree 0 with period N. Its values at all points are equal to 1. And its weight will be:
This is the SMA equation. The weights of higher-order polynomials are equivalent to some oscillators with specially selected ratios. In other words, orthogonal polynomials are SMA with some cleverly calculated additions. Legendre polynomials are very robust to noise and perform excellently in sorting applications. For example, the Legendre polynomial of the first degree looks like this.
Chebyshev polynomials can also be used for trend detection and smoothing in addition to Legendre polynomials. There are two types of such polynomials. They differ from each other in their behavior at the edges. The main advantage of these polynomials is their sensitivity to sudden price changes. The equation for these polynomials is very simple:
This is what smoothing with the Chebyshev polynomial of the 3rd degree looks like.
So far we have considered polynomials with the definition domain of +/-1, but there are polynomials with other domains. For example, Laguerre polynomial is defined for all non-negative values of the argument. Its equation looks like this:
And the shift function for its argument looks like this:
This change leads to the fact that the behavior of the Laguerre polynomial depends not only on the degree, but also on its period. This polynomial is sensitive to recent price changes. For example, this is what the Laguerre polynomial of the fifth degree looks like on a graph:
Another interesting example of orthogonality is Hermite polynomials. These polynomials are used in many areas of math and physics. These polynomials are defined for any values of the argument, and their equation looks like this:
As a result, we obtained a smoothing filter, the efficiency of which depends on the degree of the polynomial and its period.
We have considered the basic classical orthogonal polynomials. But it is quite possible to create your own version of such polynomials. For example, a polynomial that combines the advantages of the Chebyshev and Hermite polynomials is given by the equation:
This polynomial is sensitive to nonlinear trends – quadratic, cubic, etc. This is what the Chebyshev-Hermite polynomial of the 9th degree looks like on a graph:
The use of orthogonal polynomials provides a number of advantages.
The only feature of orthogonal polynomials that can be considered a disadvantage is that these polynomials handle all prices inside the polynomial. In other words, an indicator built on such polynomials “draws”. In my opinion, this feature is not a disadvantage – the indicator simply finds the best approximation when new data arrives.
The use of orthogonal polynomials imposes some limitations. The indicator period should be greater than the degree of the polynomial. For practical purposes, we can limit ourselves to the 3rd degree of the polynomial. This indicator combines SMA, linear trend and two parabolas – quadratic and cubic. This is enough to smooth out quite complex situations. But, by increasing the indicator period, we can also increase the degree of the polynomial.
Now, let’s look at some examples of the application of orthogonal polynomials in trading.
Based on orthogonal polynomials, traders can create various trading strategies. For example, using polynomial regression based on orthogonal polynomials, a trader can not only analyze past price movements, but also create a model that can adapt to current changes in the market.
As an example, let’s look at several trading strategies based on deviations from the mean.
Let’s take the simplest strategy – positions are opened when the price crosses the SMA. We will replace the moving average with an orthogonal polynomial leaving the rules for opening and closing positions unchanged:
Despite its simplicity, this strategy is quite efficient.
Let’s complicate this strategy a little and replace the price with the value of some polynomial. In other words, we will get an analogue of the strategy with the intersection of two SMAs. The result is somewhat predictable: of all possible options, the strategy optimizer preferred orthogonal polynomials.
Polynomial models can also be used in more complex strategies. If the strategy uses any indicators, you can try to replace them with orthogonal polynomials. Such a replacement could improve the strategy.
I will make some minor changes to this indicator. As I already said: SMA is a polynomial of degree 0. Instead of SMA, I will use an orthogonal polynomial of any degree. Accordingly, I will calculate the mean absolute deviation relative to this polynomial. The resulting indicator is as follows:
The trading strategy will be similar to the classic one:
The result of testing such a strategy with a 3rd degree polynomial:
Other indicators can also be constructed based on orthogonal polynomials. For example, I want to construct an equivalent of RSI. The essence is simple: first I build a polynomial, and then I count how many prices were located above this polynomial. Based on this number, I conclude that the price is overbought/oversold.
Moreover, orthogonal polynomials can be integrated into various machine learning algorithms. The flexibility of polynomial functions enables machine learning algorithms to detect complex relationships in data.
For example, polynomials can be used to generate new features from source data. Orthogonal polynomials provide independent estimates of the different components of a time series. Due to this property, they can reduce overfitting. This can improve the quality of training data and improve the performance of models.
Take any neural network and feed the values of the weighting ratios of the orthogonal polynomials to it. But in this case, it will be necessary to construct a complete system of polynomials: starting with a polynomial of the 1st degree, and ending with N-1, where N is the number of prices processed.
Orthogonal polynomials are a powerful tool for analyzing financial time series. They provide a number of benefits and allow us to assess changes in the market. Using orthogonal polynomials in trading strategies can improve their efficiency and enhance trading results.
The following programs were used when writing this article.

