Math techniques in Timing Solution


The math methods are especially interesting for me. The reason is that it is simply natural for the person with a solid math background and a working experience of the scientific researcher (20 years at the Institute of Nuclear Research in Russia, So in this article I describe the math methods presented in Timing Solution. Before going into any discussion, I would like to remind you:

All math methods used in Timing Solution can be divided on three groups: 1) descriptive statistics;  2) simple models; 3) Neural Net models with Back Testing module (spectrum, auto regression, wavelets).

Descriptive statistics methods:

These are techniques that any mathematician would perform at first to get a general impression of the analyzed time data set.

After downloading any price history data, you can immediately look at histograms for different indicators that describe this financial instrument.

This is the histogram for logarithm daily gains calculated for S&P 500 (1974-2008 years):

You can see how B. Mandelbrot's idea of "fat tails" in financial data is confirmed.

Due to the extensive use of Fuzzy logic methods, you can display these diagrams with weighted zones (all differently colored zones contain the equal amount of points):

Spectrum analysis. We have spent a lot of time with this module applying the most workable technologies for finance. It took almost 3 years to develop this module, and I can definitely say that for the stock market analysis it is necessary to use totally different approaches than a standard scientific approach.

In general this module allows to reveal the cyclic portrait of any financial instrument. Look at this spectrum calculated for S&P500 index; the relative price oscillator with 100 bars period is used as a target:


The strongest cycles here are 757 days, 41 months and 246 days.

As a target for spectrum, you can use any other indicator, like volatility,  RSI,  ADX ...

It is a standard procedure of data normalization (detrending) before any spectrum calculations. The most difficult part is finding the algorithms of spectrum calculations suitable for a real stock market. This is the point where our spectrum analysis differs from standard scientific spectrum analysis (which is concentrated mostly on finding the persistent cycles that exist only in an ideal world).

Technically our spectrum module covers three kinds of spectrum: classical, singular spectrum analysis (SSA) and multi scale SSA. The most important thing is that with Timing Solution you can generate projection lines based on the extracted cycle/cycles and conduct back testing for the models used for these projection lines (of course the spectrum is recalculated when new price bars arrive, i.e. we model the real trading).

The technology of creating fast solutions based on spectrum module is described here and here

Chaos theory module allows to analyze the stock market behavior more deeper. The R/S analysis allows to reveal so called "stochastic cycles":

As a target for R/S analysis you can use any indicator. I used daily logarithm gain in the example above.

Here I calculated R/S diagram for Dow Jones Industrial index (data include years 1885-2008). It shows that there is 4 years stochastic cycle, which definitely corresponds to the Presidential cycle. It is impossible to reveal this cycle using spectrum analysis, as the nature of this cycle is different. 

The Chaos Theory module is described here:


Simple models:

These are projection lines created with Annual Cycle module:

Here five Annual cycles for S&P500 index are shown. The red curve is Annual cycle calculated using the last 2 years of S&P500 history, while to calculate the blue projection line 34 years of price history are used. Thus the blue line points at persistent tendencies in Annual cycle while the red line shows the tendency of the latest 2 years. All other curves represent intermediate variants for Annual cycle.

You can make a forecast based on Fourier analysis just by dragging the mouse from one point to another (say from point A to point B):

Thus we define the major period for Fourier analysis, and the program automatically performs all other operations of Fourier analysis. It works like a typical charting tool (say Fibonacci retracements or Gann fans).

The analysis of Auto regression models can be performed fantastically fast. In the example below, the program has created the Auto regression (AR) model with order 4 (AR4), AR5 ... AR24. See how this AR model forecasts 1 bar ahead (or any other number of bars):

It shows that the best model is AR16. And it took us only several seconds to calculate!

We use this module a lot for artifact studies while conducting the back testing. This is a very important part of back testing procedure.

As an example, let say that somebody claims that he can forecast next day with 80% accuracy, and he forecasts not the price but its moving average. However, it might be not a forecast but some artifact.

So, we calculate that moving average and make a linear regression to forecast the next day moving average value:

Our result is 85% accurate "forecast". This has happened because the moving average is used as a target for the forecast.

If the same model is applied to forecast "close" instead of moving average, you will get zero:



Neural Network + Back Testing modules:

This combination is the most advanced feature of Timing Solution software. 

Neural Network. The heart of this module is Neural Network (NN). Timing Solution NN allows to generate projection lines based on different models.

These are important features of Timing Solution NN:

As input, you can use:

Back Testing Module. If the projection line can be calculated by Neural Network module, we can provide a detailed back testing for this model. The program divides the whole price history file on two intervals. One interval is used to calculate spectrum (if this is spectrum model) and train Neural Network. The other interval ("out of sample") serves to check how this model forecasts the future. The program performs this procedure as many times as you need.

The program excludes any kind of "future leaks", in other words there will be no surprises (like the model that earlier has worked perfectly does not work at all now).

For example the back testing process for Spectrum based model can be something like this:

a) Break the price history on training and testing intervals

b) Calculate the Spectrum diagram using price history from the training interval:

c) Extract the most important cycles from this spectrum:


d) Use these cycles as inputs for Neural Network module and generate the projection line based on these cycles:


e) Check how the program forecasts on TESTING interval (there are many criteria like calculate a correlation between the price and the projection line, %X trades based on turning points created by the projection line, or the direction of future movement).

f) The program repeats this procedure using other training and testing intervals and repeats this procedure again (recalculates spectrum, creates a new Neural Net, etc.).

Some info regarding Back Testing procedure you can find here:

If you need to get the list of the projection lines generated by different techniques, you can get a report similar to these ones:

for autoregressoion model: ar.pdf

for spectrum model: spectr.pdf

To make backtesting procedure statistically significant, usually we analyze hundreds of projection lines.

The special issue is artifact study within backtesting procedure. This is a very tricky and time consuming process. We spent 3 hard working years to reveal all (I hope) artifact effects common to forecasting.