In this lesson we discuss projection models based on fixed cycles. The idea here is that markets follow specific cycles and we will see how to find these cycles and create a forecast based on them.
The first section of this lesson discusses the basics of cycles, so if you are already familiar with it, you can skip that and and move to the application of cyclical analysis in Timing Solution here.
A cycle is something that repeats itself in time. The simplest example is a workday routine: you come to work at 9AM, do your duties, have lunch at 1PM, go home at 4:30PM; same schedule day to day. Another example is an annual cycle - from January 1 to December 31; same order of days, weeks and months, year by year. If you talk to scientists and engineers, they will add cycles in space, not only in time; an example of such a cycle is a bus route - from station A to station B, again and again.
We can talk about different cycles indefinitely. The good thing with cycles is that they make a forecast possible. If we know the cycle, we can find out where we are in this cycle, and then we can tell what happens in a minute, in an hour, next year, next kilometer, etc. Many cycles can also be described by equations and functions. It means that once a cycle is studied, we are able to program it and forecast some activity related to this cycle. This is why scientists love cycles.
In this article we will deal mostly with the cycles that can be described by harmonic functions, i.e. can be represented by some modification of sine/cosine waves.
This is a sample of sine (cosine) curve:
Any sine wave has three parameters: period - the length of the cycle, amplitude - the strength of the cycle (you can see it on the diagram as the height of the sine curve) and phase - the angle that defines the start of the cycle (the start point on the diagram is marked as "A").
It is possible to combine various cycles together (combine two different sine waves for example).
It is called superposition of
the cycles, and the result is a cycle as well. The
resulting cycle may look like this one:
In this case there is a superposition of 80, 145 and 170 day cycles. It is displayed together with Dow Jones Industrial Index chart (a black line). In regards to making a forecast, superposition of the cycles is a very useful thing as normally we have many different cycles working at the same time.
In the previous example the same weights were used for all three cycles. Suppose one of the cycles is more important than others. We can double the weight of that cycle (keep the same period and phase, but double the amplitude), changing the appearance of the resulting curve. Thus, modifying the cycle weights we can significantly improve our superposition curve. As an example, we modify the cycles from the example above. We have increasedthe weight of 145 days cycle 5 times leaving other cycles as they are; now the superposition fits the price curve better than the previous one, thus giving us a better projection line.
Suppose you touch the guitar string, and it starts vibrating. How many different sounds do you hear?
First of all, you hear the main vibration of the string; on the picture below this is the upper vibration involving the whole string length. Next, you hear the vibration of half of the string length; it is the next "octave" of the main sound. Then you hear vibrations caused by 1/3 the length of the string, 1/4, 1/5, etc. These "additions" to the main sound are called overtones. Some overtones are louder while others are quieter; it is the reason why every musical instrument makes its unique sound.
Overtones can be used not only in music. They can add something meaningful to any cyclic process. See the difference between a pure sine wave calculated by Timing Solution and the same wave with overtones - enriched wave.
This is a 145 days pure sinus wave:
This is the same wave with two overtones:
And below is the same wave with eight overtones:
When working with financial instruments, some cycles fit better than others. It is possible to collect all these cycles and compare how they fit the data. This is represented by a graph that shows the length of the cycle versus how well it fits the financial instrument. A graph like this is called a spectrogram.
A sample of a spectrogram created by Timing Solution is shown below:
This spectrogram is also called a periodogram. The X axis on this diagram corresponds to the period of the cycle, while Y is the strength of this cycle (more exactly, spectrum density). The highest peaks on this chart indicate cycles that are the strongest in this financial data (in other words, they fit the data we have the best way). The spectrogram simplifies our life: when we have it, our task is only picking up these top cycles and asking the program to make a projection line from them.
To open the Spectrogram window in Timing Solution, click this button:
The program takes a few seconds to find all the cycles that are relevant to the data and displays a Spectrogram as the one shown below:
To pick up the most important cycles from a spectrogram in Timing Solution, click the mouse around the peak you want to select:
Even if you miss the peak itself, the program automatically catches the highest point, puts this cycle into "Extracted Cycles" window and marks this cycle on the spectrogram by a vertical line.
Do this procedure several times while picking up the most important cycles:
This procedure may be performed automatically by clicking "Extr" button; the program extracts the strongest cycles. Another way is specifying the amount of strongest cycles to extract. This is an example of extracting five strongest cycles:
If this parameter is zero, the program finds itself how many cycles to extract; it maybe 2 or 3 or 4 etc. cycles.
To quickly generate a projection line based on the selected cycles click this button:
The program asks you to enter Forecast Stock Memory (it is described later in this lesson). The default number is three, it can be changed if needed.
In the Main screen, the forecast based on chosen cycles appears:
The forecast is a weighted superposition of the chosen cycles. The program finds the weight of each cycle, automatically aligning them to the previous price movements.
Instead of clicking the "wave" button, you may save some time by dragging these cycles from the "Extracted Cycles" list in the Spectrum module to the Main screen. You can click on any cycle and drag it to the Main Window, and Timing Solution creates a projection line based on all cycles that have been checked in the Spectrum Window:
The following example shows how to work with Spectrum Analyzer. After downloading the price history data (it is corn futures EOD continuous data in this example), click "Spectrum" button:
In seconds, the program makes the diagram similar to this one:
This is a periodogram, and it helps to figure out what cycles are present inside our data set and which ones are more prevalent than others.
The horizontal X axis shows the periods of analyzed cycles; in this case the periods are 30, 50, 100, 20 days, 1 year and 2 years (Your results might be slightly different due to different data being loaded):
The vertical Y axis shows the importance of the cycle, in other words the energy accumulated in this cycle. Accordingly the peaks on this diagram correspond to the strongest cycles. These cycles will be used to create a model for the projection line.
Let's look at one of these cycles closer. There is a peak around 500 days period. Clicking on this cycle extracts it for the forecast, and it is placed in the field just below the Spectrogram:
The program immediately calculates the period of this cycle. In this example, the actual period of the cycle is 499 days. Now look at the Main screen:
Here the red wave shows how this 499-days cycle works in time. It is a fixed cycle, and its wave can be prolonged for as long as needed.
In this example the amount of overtones is set to 1 to calculate a pure sine wave:
Now let's look at the overtones parameter. It allows to enrich the main sine wave. Here is the enriched 499-days wave:
The pictures above show that the amount of overtones equal to one gives a pure sine curve; when the amount of overtones is increased, the shape of that 499 day cycle wave becomes more detailed, more complex. It resembles the original price chart better than just the sine curve. Still, this curve alone is not enough to cover important characteristic points of the price chart. Maybe, the result would be better if more cycles are used.
Let's explore this idea by going back to the spectrogram and picking up two more cycles (166 and 263 days cycles). All three cycles are shown now in the Main screen. They are color coded so you can tell each cycle apart. In this case, the 499-day cycle is shown in red, the 166-day cycle is shown in blue and 263-day cycle is shown in green.
We can create a superposition of these three cycles and see how they perform relative to the price data. To do this, drag and drop these cycles from the Spectrum window onto the Main screen. Or click the Wave button on the Spectrum window.
Now the superposition curve reflects the initial price chart better than any of those three cycles on their own. So, being able to prolong these cycles as far as we like to the future, we can have a nice projection line based on these three cycles.
To delete this projection line from the Main Window, click this small button in the right bottom corner (it can be done as well by making a RIGHT mouse click in the Main window and choosing "Delete ULE event" in the pop-up menu):
Now, we have seen that several cycles provide a better result than one cycle. And we can create a projection line based on as many cycles as we like. How to choose the best cycles?
There are two criteria and one recommendation for that:
The higher the peak, the bigger the amplitude of this cycle. The narrower the cycle, the more energy is concentrated in this cycle. Take a look at this example:
The peaks at this periodogram marked by red circles (1, 3, 5) are "good" cycles; i.e. these peaks are high and the width of these peaks is narrow. There are also other peaks; they are marked by blue circles (2 and 4), these cycles are not as good because these peaks are not as narrow. It means that the energy of these cycles is distributed in a wider range. It makes these cycles less precise.
We did research for many different financial instruments trying different combinations of cycles. The recommendation is: do not use too many cycles, several cycles (1-5 cycles) are enough. You should remember that the models that use too many cycles are very good in explaining PAST price movements while they are not so good in FORECASTING future movements. Adding just one bad/unimportant cycle to your cyclical model may spoil the whole model. Be very picky while choosing cycles.
Here are the most important parameters we recommend to experiment with:
"SM" parameter ("stock memory"): this is expected "life time" of analyzed cycles. In this example SM=3; which means that this cycle may be able to forecast the future within three full cycles. For example, if we use a 100 days cycle, the program gives this cycle a "higher probability" to work within 300 days. Beyond that, the program is uncertain how well this cycle would work.
The "overtones" parameter has been explained above. We recommend to experiment with these parameters to see how they affect the projection line.
The spectrum analysis is performed for fixed cycles. You may have seen as well the mention of "dominant" and "permanent" cycles. What are they? These are just terms. And sometimes the use of these terms in other software or in the literature is confusing. Let's discuss it a bit.
Permanent cycles are more obvious. According to their name, they are there all the time. Actually, it may be just another name for cycles in general.
In Timing Solution, the distinction between dominant and permanent cycles is in the way how to take their presence in data.
By default Timing Solution is oriented on searching of dominant cycles, the cycles that have an important role for some time and then disappear. They disappear not in a sense of not existing any more. Instead, their effectiveness changes over time, for some time they would play a big role and then they would become less effective. Fixed cycles are always present, just like a sine curve that is unlimited on both sides, past and future. At any given moment, cycles accumulate or lose some portion of energy becoming more or less apparent. They do not work in the same manner all the time.
Multiframe technology is developed to catch these cycles. So when the new portion of the price data is coming, the cyclical portrait of the financial instrument is changing as well due to the changes in the periodogram. Cycles that were used initially to create the forecast model may become not as important while other cycles that were ignored earlier may start being important. It means that from time to time it is recommended to recalculate the spectrum by clicking "Recalculate" button.
To find permanent cycles (i.e. the cycles that always work the same way), set this parameter in Spectrum module:
As an example, let us try to find a permanent cycle for DJII from 1885 to 2014.
This is the spectrum for Dow Jones, and it shows the peak around the period of 40 months. It is a well known cycle for economists called Kitchen inventory cycle:
In most cases we work with dominant cycles. They are more typical for financial data, more tradable. Permanent cycles are mostly used for economical analysis, as these cycles are believed to work in the same manner now as they worked 10, 50, 100 etc. years ago.
Most financial instruments have some trends. You have heard a saying: "Trend is a friend". It may be true at certain moments for a trader, but it is not true from the point of view of Cyclical Analysis theory. When scientists evaluate data sets, the first step is to get rid of a trend and anything that can distort a statistical picture. Therefore, it is mathematically necessary to modify price data before doing anything. We have to do that as our goal is to model the market behavior and make a forecast as close as possible to the functions used in forecasting, i.e. to sin curves. To reach this goal, we do not want the general trend of the stock to be used in the forecast, so we do not use the price itself to calculate the spectrum diagram. Instead, we use the detrending indicators. One of the most popular is the relative price oscillator (or percentage price oscillator). As an example, look at this indicator with the period=100 bars:
The parameters of this indicator are defined manually in relation to swings you want that the program tries to catch. Or other indicators may serve as a forecast target - like RSI, ADX, Volatility, etc.
In other words, the program performs the spectrum analysis not for original data (as Dow Jones Industrial index in the example), with its up and down trends, but for one of its oscillators:
The oscillator is much more convenient for the cyclical analysis.
While working with intraday data, it is better to calculate the spectrum using price bar metric:
Also for intraday it is recommended to use Turbo cycles module. It extracts the most important cycles automatically and calculates the projection line based on these cycles. This projection line is updated in real time when the extra price history data is downloaded. You will find more info about this module here.
Timing Solution software has more features that apply different methods of Cyclical Analysis. Below is a short description of those features.
Wavelet Module: this module allows to see the cyclical phenomena in dynamic environment, i.e. you can see how the cycles appear-live-and disappear. More information about this module is contained here.
Committee: the same cycle/cycles can generate several versions of projection lines, this module allows to see all these projection lines together. Documentation for it is found here.
Q-Spectrum modules: this is a unique module that applies methods of Walk Forward Analysis (the standard financial analysis technology) to financial data. Its description is here.
Behind very complicated math methods used in the software (like spectrum or wavelet or some other method) lies a very simple and clear idea. We try to find the track of regular waves in financial data. All mentioned mathematical powerful tools are designed for this simple task of catching a regular wave in financial data as early as possible. Very often the simplest visual analysis of the price chart helps to reveal these cyclical patterns, and specially developed Timing Solution charting tools are very helpful here.
That is why we recommend, before working with some sophisticated tools, to apply a simplest visual cyclical analysis. It is just looking at your price chart attentively and identifying some regular patterns there.
The charting tools in the "Wave" section help you to do that:
Let's try these charting tools:
Suppose that you see a two-wave regular pattern in your price chart, like this:
To model it, we build a sine wave overlay of price chart using "Harmonic wave" charting tool:
Adjust the overtones, try and calculate half-length of the wave, one third of it, and so on. Sometimes (as shown on the picture below) they work:
For your convenience it is recommended to disable snapping mode by pushing this button (otherwise the program automatically catches the nearest highs/lows):
Take a look at A-B wave between mid of 2010 and end of 2011:
We can model this A-B wave using Fourier analysis and prolong it into the future. Choose "Fourier String (1 wave)" charting tool and drag the mouse cursor from the beginning of this wave (point A) to its end (point B). You will see this wave prolonged into the future.
This is another example. Here there are two waves in the price chart between the beginning of November 2013 and the beginning of March 2014.
To model and prolong this two-wave pattern into the future, apply "Fourier String (2 waves)" charting tool:
and drag the mouse cursor to cover two-wave pattern:
It is recommended to experiment with the amount of overtones parameter to enrich/simplify the projection line:
These are just some charting tools based on classical Cyclical Analysis methods. The software has more charting tools, and they are discussed here.
This concludes the tutorial about the basic cyclical analysis and the use of Spectrum Module. Next lesson covers Astronomy Module.
Very basics of harmonic analysis - a detailed explanation of basic definitions and methods used in harmonic analysis (periodical functions, waveforms, Fourier analysis, overtones ...)
Cyclical analysis in essence in 33 pictures - a general explanation of different cyclical models that are present now in Timing Solution software (classical cyclical analysis, wavelet analysis, astro cycles, analysis of price patterns).
Wavelet analysis: Wavelet analysis is a part of cyclical analysis especially important for financial data where practically any cycle does not represent itself forever; cycles have some restricted "living" time. Wavelet analysis issues are discussed in these articles below:
Wavelet analysis - cycles early warning system - a basic explanation regarding wavelet analysis
Wavelet Cycle Hunter - thoughts on application of wavelet analysis for financial data
Fading cycles of the stock market - the techniques of classical cyclical analysis applied in physics not always may be applied for financial data. In this article you will find the explanation why...
Q-Spectrum: Q-Spectrum is a new powerful module that allows to reveal cycles using a unique combination of methods of classical cyclical analysis and classical financial analysis (walk forward analysis). These articles illustrate the idea:
Q-Spectrum - an explanation of Q-spectrum features
Anti-Information - a discussion of new issues that Q-spectrum brings to our attention
Turbo cycles: This module automatically calculates spectrum, extracts the most important cycles and calculates the projection line based on these cycles. This is a quick way to do cycles analysis which is especially important for intraday chart; the module perfectly works in real time mode. These articles are recommended:
Turbo Cycles module - a detailed explanation how Turbo cycles module works
Back Testing for Turbo Cycles module - a description of ways to find optimal parameters for Turbo cycles models