THE POWER OF NO-LAG TECHNICAL INDICATORS IN ALGORITHMIC TRADING

In the framework of technical analysis for algorithmic trading we introduce an original approach to classical technical indicators. For this, we consider technical indicators as bounded operators: this more abstract, but also more algorithmic view enables us to define in a very simple way the no-lag versions of these tools. Delay in response is indeed a major drawback of many classical technical indicators used in algorithmic trading, which often leads to a wrong information. On the contrary, with the no-lag versions of the indicators that we study here, we get better information that is closer to the instantaneous values of the securities, hence a better expected rate of return of the trading system in which they occur. After having recalled the definitions of weighted and exponential averages as bounded operators, we prove that the lag possesses a fundamental property that is very useful to create no-lag versions of technical indicators. This being done, we apply our results to a basic trading system and test it on the S&P 500 index, in order to compare the classical Elder’s impulse system with its no-lag version and the so-called Nyquist-Elder’s impulse system: we observe on this example that the no-lag versions of indicators lead to much more profitable systems. More precisely, the Nyquist-Elder’s impulse system is much better than the Elder’s impulse system without lag, which is itself better than the classical impulse system: the information given by Nyquist-Elder’s impulse system is indeed closer to the instantaneous value of the S&P 500 index since it has less delay than the classical impulse system: Nyquist-Elder’s impulse system is even the closest to the instantaneous value among the three ones. We eventually compare the profit/loss of four portfolios (a portfolio that replicates S&P 500 index, and one for every of the three impulse systems) in order to better understand the time dynamics of our three Elder’s impulse systems. As far as we can see, we also notice a lower draw-down for the portfolio associated to the system using the Nyquist-Elder’s impulse system than for the other ones, and this portfolio seems to be more resistant to bearish periods.


Introduction and organization of the paper
Delay in response is a major drawback of many classical technical indicators used in algorithmic trading, and this often leads to useless or wrong information. The aim of this paper is to define as operators some of these classical indicators, in order to give and study their no-lag versions: these no-lag versions provide better information that is closer to the instantaneous values of the securities, hence a better rate of return of the trading system in which they occur.
The first section of the article will be devoted to the study of the lag of a weighted moving average and to the presentation of its fundamental property; we will also make use of Nyquist criterium. These results will enable us to give no-lag versions of wellknown indicators that we will compare through a very simple example of trading system: this example will show the power of no-lag indicators.
For any security, we denote by ( ) the bounded sequence that consists of its prices at times For example, we may consider the daily or monthly prices of this security. We also denote by the difference between two consecutive time measures, i.e. .

Weighted and exponential averages
The weighted moving average with periods and the weights ( ) is the bounded operator defined, for every price series , by ( ) , where We can also define and for every positive integer .
When we want to give more importance to the most recent prices, we usually use exponential moving averages, which are bounded operators defined as follows: for between and , we set ( ) , with and, for every positive integer ,

( )
If has the form , we denote the exponential moving average by and we call the number of periods of .

The fundamental property of the lag
Here, we shall use some results obtained by Patrick Mulloy in the article [8] (see also [2; 4]). The lag of the weighted moving average is defined by For example, for the simple weighted moving average with periods defined by its lag equals ( ) .
We can show that the lag of a weighted moving average possesses the following fundamental property: the lag of is equal to ( ) ( ). In a more concise way, this means that for every polynomial , we have the formula ( ( )) ( ) ( ). For math lovers, the proof of this result can be found at the end of the article.
We can now get no-lag versions of weighted moving averages: we can show that is the only combination of and of the form with whose lag is zero. We denote it by Р( ): this no-lag weighted moving average will be very important in the following. Let also note that is an interesting no-lag combination of degree .

Using Nyquist criterium
Using Nyquist criterium is another way to reduce the lag of a moving average. Here we use some results obtained by Dürschner in his article [3] and consider two simple weighted moving averages and with respectively and periods: their weights are thus defined by

Fig. 1. Nyquist criterium ( )
Source: developed by the author from article [3] We set . Then, the Nyquist moving average with periods is the bounded operator defined by

( )
In order to satisfy stability Nyquist criterium, the numbers and must verify the inequality .

Technical indicators without lag
Here, we make use of the results of previous section in order to define technical indicators "without lag". We begin with the exponential moving average and the MACD, and then we use these tools for Elder's impulse system.

MACD without lag
Let us recall the definition of the MACD (moving average convergence divergence) introduced by Gerald Appel in 1979 in his financial newsletter "Systems and Forecasts" and presented in his book [1]: first we set , then (the average series of ) and (the divergence series). Now, for any parameter between and , the exponential moving average without lag is defined by ( ). Then, we can define the MACD without lag by replacing every exponential moving average by its no-lag version: first we set and (the average series of ), and (the divergence series). These three operators are bounded operators.
In the same way, the Nyquist-MACD can be defined by replacing every exponential moving average by a Nyquist moving average: first we set , then (the average series of ), and finally (the divergence series). Here again, these three operators are bounded operators.

Elder's impulse system without lag
By using the exponential moving average without lag and the MACD without lag, we can give a "no-lag version" of Elder's impulse system.
Let us first recall the definition of the impulse system introduced by Alexander Elder in his best-seller [5]: this technical indicator can be seen in an algorithmic way as an operator that associates to every time a color that depends on the price series of the security. The chosen colors are red, green, blue, and they are respectively denoted by " ", " " and " ".
We give the algorithmic definition of Elder's impulse system above, and we define its "no-lag version" and the so-called Nyquist-Elder's impulse system in the box below.  [5] On the graph below we can see the three versions of Elder's impulse system that we defined. As we can observe it, the beginning of the downtrend (denoted by 1 on the graph) in the index price is detected earlier by Nyquist-Elder's impulse system than by the no-lag version of Elder's impulse system, which itself detects it earlier than its classical version.
In the same way, the beginning of the uptrend (denoted by 2 on the graph) and the beginning of the second downtrend (denoted by 3 on the graph) are first detected by Nyquist-Elder's impulse system, then by the no-lag version and the classical version of Elder's impulse system.

Comparison of the three versions of Elder's impulse system
Here we use the very simple trading system given by the following algorithm (box Algorithm 1), in order to compare the three versions of Elder's impulse system. This trading system simply consists of buying (resp. short selling) 1 E-Mini S&P 500 future when an impulse system given by a function is green (resp. red) and selling it when this impulse system becomes red (resp. green).
Let us mention that in this trading system, every position is automatically closed one day before the end of the test. We use ( ) the daily price series of the S&P 500 index during the time period from 2017-11-01 to 2018-10-31. The reader who wants to learn more interesting information on trading systems can look at the books [7; 9].  We use the algorithm above with , and , and we assume that the transaction cost for every entry/exit is . The results are given by the following table, in which all prices are in USD. Let us note that the value of the S&P 500 index is (resp. ) on 2017-11-01 (resp. 2018-10-31), hence a profit of for one mini contract during this period.

Conclusion and perspectives
Comparing on this example the three versions of Elder's impulse system is very instructive. Here we observe in particular that the Nyquist-Elder's impulse system is much better than the Elder's impulse system without lag, which is itself better than the classical impulse system: the information given by Nyquist-Elder's impulse system is indeed closer to the instantaneous value of the S&P 500 index since it has less delay than the classical impulse system: Nyquist-Elder's impulse system is even the closest to the instantaneous value among the three impulse systems. Therefore, it leads to less wrong trade setups. We can also note that the number of trades as well as the average net profit per trade are increasing when is respectively equal to , and . And the repartition of profit among long and short trades is more uniform with and than with .
In order to better understand the time dynamics of our three Elder's impulse systems, we consider the profit/loss of four portfolios as a function of time: portfolio 1 replicates S&P 500 index, portfolio 2 consists of profit/loss given by the algorithm above applied to , portfolio 3 consists of profit/loss given by the algorithm above applied to , portfolio 4 consists of profit/loss given by the algorithm above applied to .
As we already noticed it, portfolio 4 is much more profitable than portfolio 3, itself better than portfolio 2, and of course much better than portfolio 1. Portfolio 4 also possesses a lower draw-down than the other ones, and it seems to be more resistant to bearish periods. In view of the results of this example, it could be useful to study how no-lag impulse system and Nyquist-Elder's impulse system behave in much more elaborate trading systems. Moreover, a statistic study could help us to determine how to adapt the parameters in order to get the fastest response to market motion.