Schweitzer Fachinformationen
Wenn es um professionelles Wissen geht, ist Schweitzer Fachinformationen wegweisend. Kunden aus Recht und Beratung sowie Unternehmen, öffentliche Verwaltungen und Bibliotheken erhalten komplette Lösungen zum Beschaffen, Verwalten und Nutzen von digitalen und gedruckten Medien.
“It is too complex,” said Tom simply.
Simplicity is at the heart of the concept of linear systems. Input data are supplied to the system, and the system provides the resultant as an output. There is only one input and only one output. However, the system between the input and output can be as complex as desired. The output divided by the input is the transfer response of the system. It is this transfer response that describes the action of the system.
In this chapter you will find the difference between nonrecursive filters and recursive filters, and combinations of the two, enabling you to select the best filter for each application. In addition, you will find that the responses in the time domain and in the frequency domain are intimately connected. When designing filters for trading, it is beneficial to consider the response in both of these domains. It is important to remember that no filter is predictive—filter responses are computed on the basis of historical data samples.
By thinking in terms of the transfer responses, you will easily make the transition between filter theory and programming the filters in your trading platform.
Consider a four-bar simple moving average. The input data are the last four samples of price. The filter output is one-fourth of the most recent price data plus one-fourth of the data sample delayed by one bar plus one-fourth of the data sample delayed by two bars plus one-fourth of the data sample delayed by three bars. If we allow the symbol Z −1 to represent one unit of delay, then we can write an equation for the transfer response of a simple moving average (SMA) as:
(1-1)
The values of ¼ are called the coefficients of the filter. In general, the filter coefficients sum to 1, so the ratio of the input to the output is 1 if the input is a constant. If we choose to generalize the filter to be other than an SMA, the values of the coefficients can be arbitrarily assigned. Further, we can extend the filter to have any arbitrary length. In this case, the filter transfer response can be written as:
(1-2)
The interesting thing about this equation is that we have now written the transfer response as a generalized algebraic polynomial. The polynomial can have as high an order as desired.
The filter generality can be extended by writing the transfer response as the ratio of two polynomials as:
(1-3)
This equation completely describes the transfer response of any filter. The only thing that differentiates one filter from another is the selection of the coefficients of the polynomials. It is immediately apparent that the more fancy and complex the filter becomes, the more input data is required. This is really bad for filters used in trading because using more data means the filter necessarily has more lag. Minimizing lag in trading filters is almost more important than the smoothing that is realized by using the filter. Therefore, filters used for trading best use a relatively small amount of input data and should be not be complex.
Although mathematicians will cringe at the notation, filter computations can perhaps be better understood by simplifying Equation 1-3 as:
Clearing fractions by cross multiplying, we get an equation useful for programming:
(1-4)
Equation 1-4 says that the filter output is comprised of two parts. The first part, the numerator term, uses only input data values. If that is the only term used in the filter, the filter is said to be nonrecursive. The second part, the denominator term, consists of previously computed values of the output. Filters using any previously computed values of the output are said to be recursive. The distinction is important because it is difficult to create recursive filters in some computer languages used for trading. Parenthetically, the coefficient a0 is usually unity to keep things simple.
A nonrecursive filter is one where the output response depends only on the input data and does not use a previous calculation of the output to partially determine the current value of the output. Nonrecursive filters have wide applications and therefore have acquired many different names. Among the aliases are:
SMA filters are a special case of moving average filters where all the filter coefficients have the same value.
One of the most important filter characteristics to a trader is how much lag the filter introduces at the output relative to the input. A nonrecursive filter whose coefficients are symmetrical about the center of the filter always has a lag equal to the degree of the filter divided by two. For example, a nonrecursive filter of degree six will have a three-bar delay. This delay is constant for all frequency components. Since lag is very important, and since lag is directly related to filter degree, filters used for trading most generally are simple and are of low degree.
If the a0 coefficient equals one and all the other “a” coefficients are zero, the most general transfer response is just the simple polynomial in the numerator. From the fundamental theorem of algebra, the polynomial can be factored into as many complex roots as it has degrees. In other words, the transfer response can be written as:
(1-5)
The coefficients may be complex numbers rather than real numbers. In this case, the roots of the polynomial are called the zeros of the transfer response. For example, the four-bar SMA transfer response is a polynomial of degree three and therefore has three roots factored as:
(1-6)
This transfer response has one real root and two complementary imaginary roots. If we substitute an exponential as exp(−j2π f) = Z −1, in the real root portion of Equation 1-5, we get using DeMoivre's theorem:
(1-7)
This equation can be true only when the frequency is half the sampling frequency. Half the sampling frequency is the highest frequency that is allowable in sampled data systems without aliasing, and is called the Nyquist frequency. In our case, the sampling is done uniformly at once per bar, so the highest possible frequency we can filter is 0.5 cycles per bar, or a period of two bars. Equation 1-7 shows that the zero in the transfer response occurs exactly at the Nyquist frequency. We have succeeded in completely canceling out the highest possible frequency in the four-bar SMA.
We can see the frequency characteristic of the transfer response by starting with a five-element SMA and then generalizing.
Multiplying both sides of this equation by Z −1 and subtracting that multiplicand from both sides of the equation, we obtain
We get the frequency response of this five-element SMA by making the substitution Z −1 = exp(−j2π f ), where f is the sampling frequency. Then,
The equality of the exponential expressions and the sine equivalent will be recognized by readers familiar with complex variables as DeMoivre's theorem. For readers without this math background, please accept it on faith.
Generalizing this result for an N-length SMA, we have the transfer response of an SMA in the frequency domain expressed as:
But since the Nyquist frequency is half the sampling frequency, the transfer response in the frequency domain is
(1-8)
where f = frequency relative to the sampling frequency
The important conclusion from this discussion is that we can think of the transfer response with equal validity in the time domain or in the frequency domain.
When we plot the response of the four-element SMA as a function of frequency in Figure 1.1, we see that we not only have a zero at the Nyquist frequency, but also at a frequency of 0.25.
Figure 1.1 Frequency Response of a Four-Bar Simple Moving Average
The horizontal axis is plotted in terms of frequency rather than the cycle period that is most familiar to traders. Frequency and period have a reciprocal relationship, so a frequency of 0.25 cycles per bar corresponds to a four-bar period. The vertical axis is the amplitude of the output relative to the amplitude of the input data in decibels. A decibel (dB) is a logarithmic measure of the power in the output. Figure 1.1 shows that there are zeros in the filter transfer response in the frequency domain as well as in the time domain.
The concept of thinking of how a filter works in the frequency domain as well as how it works in the time domain is central to the understanding of the indicators that will be developed. Low frequencies near zero are passed from input to output with little or no attenuation. Since higher frequencies are blocked from being passed to the output, the SMA is a type of low-pass filter—passing low frequencies and blocking higher frequencies. Low-pass filters are data smoothers that remove the higher-frequency jitter in the input data that often makes the data...
Dateiformat: ePUBKopierschutz: Adobe-DRM (Digital Rights Management)
Systemvoraussetzungen:
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „fließenden” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein „harter” Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.Bitte beachten Sie: Wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!
Weitere Informationen finden Sie in unserer E-Book Hilfe.