Basics of cyclical analysis (period, amplitude and phase), Spectrogram, Superposition, Adding weights to cycle's parameters, Overtones, Nyquist frequency, Spectrum Analyzer, Choosing cycles for the projection, Stock memory, Dominant cycles versus permanent cycles, Detrending, Fixed cycles for intraday data, Turbo Cycles module, Advanced techniques based on fixed cycles, Visual cyclical analysis
In this lesson we discuss projection models based on fixed cycles. It starts with the basics of cyclical analysis. If you are a busy person, you may skip this section and follow Easy Start section here.
Basics of cyclical analysis
The cycle is something that repeats itself in time. The simplest example is a workday routine: enter your office 9AM, do your duties, 1AM is lunch-time, 4:30PM go home; same schedule day by day. Another example is a year-round cycle, 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; the simplest example of such a cycle is a bus route - from station A to station B, again and again. Waves - different waves - are also samples of the cycles.
We can talk about different cycles indefinitely. The most fascinating thing with the cycles is that they make possible a forecast. If we know the cycle, it is easy: find out where you are in this cycle, and you are able to tell what will happen in a minute, in an hour, next kilometer, etc. This is why the scientists love cycles. There is one more reason for this love: many cycles can be described by equations and functions. It means that (knowing a cycle, of course) we are able to program the cycle and forecast some activity related to this cycle.
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 sinus/cosine waves.
This is a sample of sinus (cosine) curve:
To describe any sinus wave, you need to know: a period - the length of the cycle, amplitude - the strength of the cycle (you can see it on the diagram as the height of the sinus curve) and a phase - the angle that defines the start of the cycle (the start point on the diagram is marked as "A").
Mathematicians know many ways to play with the cycles. They have found a way to summarize several cycles at the same time. It is called superposition of the cycles; the result is a cycle as well. The resulting cycle may look like this one:
Here I did the summation of 183.1, 135.5 and 87.6 days cycles. It is displayed together with Dow Jones Industrial Index chart (a black line) and its 300-bar detrended oscillator. In regards to our main goal, making a forecast, superposition of the cycles is a very useful thing as normally we have many different cycles working at the same time.
Other interesting things that you need to know about the cycles are:
Weighting: In the previous example the same weights were used for all three cycles. Imagine that you know that one of the cycles is more important than others. You can assign to that cycle double meaning (same period, same phase, double amplitude). It leads to a different appearance of the resulting curve. Thus, playing with cycle weights we can significantly improve our superposition curve.
Overtones: Suppose you touch the guitar string, and it starts vibrating. How many different sounds do you hear?
First of all, you will hear the main vibration of the string; on the picture above this is the upper vibration involving the whole string length. Besides, you will hear the vibration of the half of the string length; it is the next "octave" of the main sound. Also you will hear 1/3, 1/4 .. length vibrations. These "additions" to the main sound are called overtones. Some overtones sound loudly while others are very quiet; 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 sinus wave calculated by Timing Solution (a red one) and the same wave with the overtones - enriched wave (a green curve):
I used there 6 overtones.
Nyquist frequency: it is named after the Swedish-American engineer Harry Nyquist; he has spent a lot of time determining the minimal time tick to be able to see a cycle. For us, it is important to remember that if we are working with daily data, it is no use to try catching the cycle lesser than two days (nyquist frequency); if we have 15 minutes data, the 30 minutes is the shortest cycle to use. Based on my practice, I would recommend using 5-7 time intervals; i.e. for daily data use the cycles with a period higher than 5-7 days, for 5 minutes data 25-35 minutes cycles etc. I would say that Nyquist frequency is a door to a kingdom of Chaos. Keep this door locked.
Try to produce different sounds in a small room. You will easily find out that some of them sound very well there, loud, you can enjoy them; while others sound very quiet, the room absorbs them. You may say that the room itself "likes" some sounds and "does not like" others. You can imagine the spectrogram as a result of "asking" some financial instrument how well a cycle fits to it.
See a sample of a spectrogram created by Timing Solution. Download any financial data and click "Spectrum" button. You will get something like this:
This is a spectrogram, or periodogram. The X axis on this diagram corresponds to the period of the cycle (or a frequency of the sound in the example above), while Y is a strength of this cycle (more exactly, spectrum density). If we compare this periodogram to the sounds in the small room, the highest cycles for our financial instrument are like the loudest sounds in that room. The periodogram 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.
Picking up the most important cycles
This is a very simple procedure with Timing Solution software. Just click the mouse around the peak you want to catch:
Even if you are missing the peak itself, the program automatically will catch the highest point, put this cycle into "Extracted Cycles" window and mark this cycle on the spectrogram by a vertical line.
Do this procedure several times while picking up the most important cycles:
You can also perform this procedure automatically: click "Extr"
button and define the amount of the strongest cycles you need to extract (four
cycles in this example):
One mouse click - and the forecast is ready
If you picked up the most important cycles, click this button:
In the Main screen, the forecast based on chosen cycles appears:
As you have guessed already, 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 movement.
To save some seconds instead of clicking the "wave" button, you may simply drag these cycles from the "Extracted Cycles" list in the Spectrum module to the Main screen:
So, let's start. After downloading the price history data (corn futures EOD continuous data in this example), click "Spectrum" button:
In seconds, you get the diagram similar to this one:
This is a periodogram, and it helps to figure out what cycles are present inside our data set as well as to see which ones are important and which ones are not so important.
X axis here shows the periods of analyzed cycles; you can see here the periods 30, 50, 100, 20 days, 1 year and 2 years (logarithm scale is employed here):
The vertical Y axis shows the importance of the cycle, 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 our projection line.
Let's look at one of these cycles closer. You see, there is some peak there around 500 days period. Make the mouse click around this 500 days peaks:
The program immediately calculates the period of this cycle. In the example, the period of this cycle is 499 days. Now look at the Main screen:
There the red wave shows how this 499-days cycle works in time. It is a fixed cycle, and its wave can be prolonged as long as you like.
In this example of pure sinus wave calculation the amount of overtones is set to 1:
Now let's play with overtones parameter. This parameter allows to enrich our wave. Here is the enriched 499-days wave:
As you see on the examples above, when the amount of overtones is one, the wave is a pure sinus curve; when the amount of overtones is increased, the shape of our 499 days wave becomes more detailed, more complex. Its image reminds the initial price more than the sinus curve. Still, this curve alone is not enough to cover important characteristic points of the price chart. Maybe, the result would be better if we use more cycles, not just that one?
Let's go back to our periodogram and pick up there two other cycles (166 and 263 days cycles):
Now in the Main screen you can see how these three cycles work in time (red - 499 days cycle, blue - 166 days cycle and green - 263 days cycle).
We can make a curve that is a superposition of these three cycles. Looks like it reflects better our initial price chart than anyone of these three cycles by itself. 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 create this projection line, drag and drop these cycles into the Main screen. You immediately get the composite projection line which is based on these three cycles:
or the same result can be achieved by clicking "Wave" button:
To delete this projection line from the Main screen click this small button in the right bottom corner (you can also do it making RIGHT mouse click in the Main window and choosing "Delete ULE event" in the pop-up menu):
What cycles are important and what cycles are not so important?
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 cycles?
There are two criteria and one recommendation for that. Here they are:
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 so good because these peaks are not so narrow. It means that the energy of these cycles is distributed in a wider diapason that makes these cycles less precise.
We did a 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) is 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 not good/not important cycle to your cyclical model may spoil the whole model. Be very picky while choosing cycles.
Parameters to vary
Here are the most important parameters we recommend to vary:
"SM" parameter ("stock memory"): this is expected "life time" of analyzed cycles. In this example SM=3; it means that this cycle may be able to forecast the future within three full cycles. For example, if we analyze 100 days cycle, the program gives this cycle a "legacy" to work within 300 days.
The "overtones" parameter has been explained above. We recommend to play with these parameters; you will see yourselves how they affect the projection line.
Dominant cycles versus permanent cycles
"By default" Timing Solution is oriented on searching of dominant cycles, the cycles that live some time and disappear. Multiframe technology is developed to catch these cycles. So when the new portion of the price data is coming, the cyclical portrait of our financial instrument is changing as well due to the changes in the periodogram. Cycles that you used for your model may become not so important while other cycles that you ignored earlier start being important. It means that from time to time you have to recalculate Spectrum clicking "Recalculate" button. (Cycles do not disappear; fixed cycles are present always - remember our first sinus curve? it is unlimited to both sides, past and future. They do not disappear; they just accumulate more energy or lose some of it; their importance at the moment is changing. We consider them as not working always in the same manner.)
If you are searching permanent cycles (i.e. the cycles that work always the same way), set this parameter in Spectrum module:
As an example, let us try to find some permanent cycle for DJII since the year 1885 till now (February 2014).
This is spectrum for Dow, and it shows the peak around the period of 40 months. It is a well known for economists Kitchen inventory cycle:
In most cases we will 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.
Detrending, or what to forecast?
Mostly the financial instruments have some trends. Therefore, it is mathematically necessary to use indicators instead of the price data: our goal is to forecast as close as possible to the functions used in forecasting, i.e. sin curves. To reach this goal, we do not use the price itself to calculate the spectrum diagram. Instead, we use the detrending indicator - the relative price oscillator with the period=100 bars (as an example; you may use other oscillators):
You can set this parameter manually depending on what swings you want to catch. Or you can use other indicators as a forecast target - like RSI, ADX, Volatility and others.
In other words, in this particular case we perform the spectrum analysis not for Dow Jones Industrial index with its up and down trends, but for its oscillator:
This oscillator is much more convenient for the cycle analysis.
Working with intraday data
If you are working with intraday data, it is better to calculate the spectrum using price bar metric:
Also for intraday Turbo cycles module is recommended. 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 new pieces of price history arrive. Here you will find more info about this module.
Three steps ahead
Wavelet cyclical model: this module allows to see the cyclical phenomena in dynamic, i.e. you can see how the cycles appear-live-and disappear. More information about this module you can find here: http://www.timingsolution.com/TI/7/index.htm
Walk Forward Analysis of cyclical models: http://www.timingsolution.com/TI/5/index.htm
Visual cyclical analysis
Behind a very complicated math - like spectral or wavelet or some other analysis - lies a very simple and clear idea. We try to find the track of regular waves in financial data; all mentioned mathematical powerful weapons 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 allows 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 two waves regular pattern in your price chart, like here:
To model it, we build a sinus wave overlay of price chart; do it using "Harmonic wave" charting tool:
Play with overtones, try them 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 we recommend to disable snapping mode pushing this button (otherwise the program automatically catches the nearest highs/lows):
Fourier String (1 wave):
Look at A-B wave between mid of 2010 and end of 2011:
We can model this A-B wave using Fourier analysis and prolonging 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.
Fourier String (2 waves):
This is another example. Here we see two waves in the price chart between the beginning of November 2013 and the beginning of March 2013.
To model and prolong this two waves pattern into the future, we choose "Fourier String (2 waves)" charting tool:
and drag the mouse cursor to cover this two waves pattern:
We recommend to play with the amount of overtones parameter to enrich/simplify our projection line:
Charting tools are discussed here.
More about cyclical models available in Timing Solution can be find here.