How can century-old functions update your trading strategies?
Introduction
Analysis of the current state of the financial market is the most important basis for successful trading. It allows traders to assess the current situation, predict possible price changes and make informed trading decisions. Various mathematical methods and models can be used for it.
In this article, we will discuss several new mathematical functions. Well, not exactly new. They were new about 100 years ago. Now some functions are well forgotten, while some are applied. But, for some reason, not in trading. Let's try to correct this annoying shortcoming.
Rademacher functions
From a mathematical point of view, a function is a correspondence between the arguments of a function and its values. They may look like this, for example:
![]()
In trading such functions are used very rarely. Window functions are most commonly used in technical analysis:
![]()
The essence of these functions is very simple. A predetermined number of prices is taken. Each price is multiplied by some ratio, calculated in some very tricky and confusing way. The obtained values are summed up and the result is an indicator. In other words, the indicator is a function of the price. And now we are faced with the main question of trading: where to find simple and understandable ratios.
The indicator coefficients can be set using the Rademacher functions. The equation for this function is very simple:
![]()
where p is the function order, and 'sign' is the sign function:

This function looks even simpler. For example, a first-order function is represented by two segments.

If we connect the ends of these segments to zero, we will get the same sine, only square. "Quadratisch. Praktisch. Gut". However, in this form, this function is not suitable for trading. We need to make some changes to it to get a discrete version.
Let's assume that we decide to create an indicator based on Rademacher functions. First, let's set its period of N. Then the value of the i th ratio of this indicator can be calculated using the equation:

For example, this is what the discrete Rademacher function of the 2 nd order with period 8 looks like.

Now we can start developing an indicator based on these functions. The indicator period should be equal to a power of two:
![]()
Then the indicator will consist of Rademacher functions of order from 0 to s. For example, for an indicator with a period of 4, we can use functions of orders 0, 1 and 2.
Let's see how such an indicator will work. First, we need to calculate the values of all functions at each reading of our future indicator.
| p = 0 | 1 | 1 | 1 | 1 |
| p = 1 | 1 | 1 | -1 | -1 |
| p = 2 | 1 | -1 | 1 | -1 |
Now, we need to find the weight of each feature. To do this, we multiply the function ratios by the corresponding prices and sum the results. After that, we divide the resulting sum by the indicator period. We will get three weights for each function:

The weight of the 0 th order function is familiar to everyone - SMA. All other weights can be represented as average speeds of a linear trend with a shift and a decrease in the trend periods.
Knowing the weighting ratios of the functions, we can begin calculating the indicator values. To do this, we need to multiply the weights by the values of the Rademacher functions that correspond to a given indicator reading. To put it simply, when calculating weights, prices were fed into the input and summation was carried out by rows. When calculating the indicator, weights should be supplied as inputs, and summation should be performed by columns. We get four indicator values:

In other words, a change in one price leads to a change in the indicator values along its entire length. On the one hand, we could see what it is drawing. On the other hand, we can say that the indicator changes its price movement model in accordance with new data.
Can you already imagine what such an indicator might look like on a chart? There are several options here. When constructing an indicator, we are not obliged to use the full set of Rademacher functions, but rather to limit ourselves to some lower order. For example, an indicator with a period of 16, built on functions with an order of 0 – 2, looks like this:

The main feature of the indicator built on Rademacher functions is that it does not strive to smooth the price. It considers any price changes as a combination of several linear trends and derives the average levels of these trends.
Walsh functions
Any time series can be modeled using trigonometric polynomials. Price movements can be arbitrarily complex, but well-chosen ratios for the sines and cosines guarantee an exact match between the values of the polynomial and the time series.
However, calculating sines and cosines is a challenging task. Walsh functions help us to significantly simplify the calculations. Typically, these functions are defined as follows... I looked at their definition and understood why they are not popular among traders.
In general, the classical definition of Walsh functions does not suit us. We need something simple and clear. Therefore, we will calculate the function of order p as follows:

This approach to defining Walsh functions allows us to construct a very discrete analog of the discrete Fourier transform. Functions with cosines correspond to the real parts of this transformation, and functions with sines to the imaginary part. Sine functions track trends, while cosine functions track moments of trend changes. Thanks to this combination, the indicator smooths prices, and the higher the order of the functions, the stronger the smoothing.

The only limitation is that the order of functions cannot exceed the indicator period. For example, you decide to use an indicator with a period of 8. Then you can use functions with order 0 - 7.
Break the system, trade freely
The functions we have looked at have already proven their usefulness. Look at your mobile phone - it has Walsh functions somewhere inside it. But... In any business there is always this "but". If it is not there, then either everything is really perfect (which is unlikely), or they are not telling you something. Let's break the rules, but not out of hooliganism, but out of a desire to expand horizons.
Rademacher functions are built on sines. Sine is an odd function:
![]()
Nobody really knows what this means, but (again, that "but") with the help of this oddness, it is possible to display trend patterns of price movement. What if we want to smooth out the price range? Then we need some even function. For example, cosine.
The smoothing version of the Rademacher function of p order can be defined as follows:

The indicator built on such functions will also track trends. But these trends will be measured relative to the center of the indicator. In other words, it will show the moments of change in the direction of the trend.

The system of Walsh functions is analogous to the system of trigonometric polynomials. Or the Fourier transform. These functions were originally developed as a simple replacement for this transformation. Walsh functions are not as accurate, but their calculation was very fast and with a minimum of steps. For computers of that time, this circumstance was critical.
But (here comes a "but" again), there is another transform that can be used to build another system. It is Hartley transform. This transform is based on the sum of sines and cosines. The ratios of such a function can be calculated as follows:

The functions can be symmetrical, then they will smooth out prices. Or they can be asymmetrical, then these functions will track trends. The indicator built on these functions looks like this.

The next change we will make concerns the appearance of the indicator. Any 0 th order function is equivalent to SMA. But we are used to the fact that SMA is displayed as a line on the chart. Let's do the same - on each bar we will calculate only the last value of the indicator and display it on the chart. Then we will see the usual line.

An oscillator can also be built based on these functions. The indicator itself will require only minor changes. All ratios of 0 th order functions should be set to zero. Then, the resulting oscillator will show fluctuations of the linear indicator relative to the SMA.

The last two indicators are calculated using differences, so their lag will be small. This can have a positive impact on trading.
Trading strategies
Now let's look at how these indicators can be used in trading.
In the first strategy, I will use the indicator's ability to track trends. The rules of the strategy are very simple:
- if the current price is below the lowest indicator value, and the previous price is above the current one, then open a buy position and close a sell position;
- if the current price is higher than the highest indicator value, and the previous price is lower than the current one, then open a sell position and close a buy position.
Despite its simplicity, the strategy appears to be quite effective.

Based on a linear indicator, you can build a strategy whose signals are generated when the price and the indicator line cross:
- if the current price is above the indicator line, and the previous one was below, then open a buy position and close sell positions;
- if the current price is below the indicator line, and the previous one was above, then open a sell position and close buy positions.

The test results are pretty mediocre. But you can always use several indicators, each with its own parameters. Each indicator will generate its own signals and bring its own small income.
We can make some small changes to this strategy by using the values of another indicator instead of price values. Intuition suggests that one indicator should be smoothing and the other should be trend-following. The result of these changes may be as follows.

To generate signals, we can also use an oscillator built on the functions discussed.
Let's try the simple option first. Let the signals be generated when the indicator line crosses zero. If the oscillator changes sign from minus to plus, then we open a buy position and close a sell position. When the sign changes from plus to minus, the opposite signal is generated.
This approach does not inspire much confidence, and its use in practice appears extremely questionable.

Let's make some changes to this strategy. Buy positions will be opened if the oscillator reaches a certain set minimum value. Sell positions will be opened if the indicator value rises above a certain level. Positions will be closed when the oscillator crosses zero.
Changing the signals for opening positions improves the results somewhat.

If you are not satisfied with the results you get, you can always try changing the settings.

As you can see, the use of new indicators in trading is quite justified. At the same time, the functions discussed in the article allow us to build more complex strategies. All functions of order 1 and higher are independent oscillators. You can build a bank of oscillators based on functions of different types, orders and periods. Based on these indicators, you can get more accurate trading signals.
Conclusion
The use of "new old" functions in trading opens up certain opportunities for price movement analysis and making trading decisions. They can help identify hidden patterns in price behavior and predict future changes. Based on these, effective trading strategies can be developed. In addition, Rademacher and Walsh functions can be used to filter out noise and improve the forecast quality.
The following programs were used when writing the article:
| Name | Type | Features |
|---|---|---|
| New Function | Indicator |
|
| New Function Lin | Indicator | The indicator calculates the last known value of the selected system of functions and displays it on the chart. |
| New Function Osc | Indicator | The oscillator built on functions of order 1 and higher. |
| EA New Function | EA | To generate signals, the deviation of the current price from the minimum/maximum values of the functions is used. |
| EA New Function Lin | EA | Signals are generated when the price crosses the New Function Lin indicator line. |
| EA New Function Lin 2 | EA | Signals are generated when the lines of two New Function Lin indicators cross. |
| EA New Function Osc | EA | EA signals are generated when the New Function Osc indicator line crosses zero. |
| EA New Function Osc 2 | EA | EA signals are generated when New Function Osc indicator line crosses the specified levels. The level values are set in the LvlBuy and LvlSell inputs. |
Translated from Russian by MetaQuotes Ltd.
Original article: https://www.mql5.com/ru/articles/17252
Warning: All rights to these materials are reserved by MetaQuotes Ltd. Copying or reprinting of these materials in whole or in part is prohibited.
This article was written by a user of the site and reflects their personal views. MetaQuotes Ltd is not responsible for the accuracy of the information presented, nor for any consequences resulting from the use of the solutions, strategies or recommendations described.
Automating Trading Strategies in MQL5 (Part 39): Statistical Mean Reversion with Confidence Intervals and Dashboard
Reimagining Classic Strategies (Part 18): Searching For Candlestick Patterns
Developing a Trading Strategy: The Triple Sine Mean Reversion Method
Formulating Dynamic Multi-Pair EA (Part 5): Scalping vs Swing Trading Approaches
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use