© 2016 by Marcello Calamai


In this example the genetic algorithm optimizes the parameters of a MACD indicator, in order to get a gain in the short-medium term. The GA can also be employed to perform a stock-picking of best securities, based on their performances.


Atlantia (ATL.MI) stock (click to enlarge)
The strategy is based on the combination of two indicators, one for the trending periods of the market and one for the ranging ones. The mix and the weights of indicators are selected by a genetic algorithm in order to obtain maximum performance and minimum volatility. The system takes positions based on the consent of both types of indicators, for gaining in tranding phases and limiting the losses in the ranging ones.
Images show the strategy applied to NZD/USD and GBP/USD exchange rates.


NZD/USD exchange rate (click to enlarge)
GBP/USD exchange rate (click to enlarge)

This is both an example of adaptive indicator and of pattern recognition.  The genetic algorithm optimizes the parameters of 3 Donchian Channels (number of days for min and max lines). It also optimizes a table of patterns describing the position of price in relation to Donchian min, max and average lines. 

Image shows the strategy applied to EUR/USD 1 hour exchange rate.

EUR/USD 1 hour exchange rate (click to enlarge)

Inspired and based mainly on the research of prof. James P. Crutchfield, this experiment tries to unveil the information processing embedded in the dynamical behavior of the market.
The task is implemented using Markov Chains, a particular type of Finite State Automata that describes transitions between states in a probabilistic way. This research is actually in a very early stage.


Markov Chains Builder

The main issue about building a computational model from raw data is that you can't use a trial-and-error method to find the best algorithm. To accomplish this goal, indeed, you should evaluate a very big set of different algorithms and the process would be, if possible at all, extremely time consuming.


This experiment tries to get over this issue by using a Universal Turing Machine (UTM). UTMs behave like a universal computer, being able to implement any algorithm given the appropriate table of rules. This allows us to use a trial-and-error method for easily selecting the best table implementing the computational model. The selection is made by means of a genetic algorithm rather then a simple random process.
Turing Machines were introduced as a universal calculation theoretical model in 1936 by the british mathematician Alan Turing. It's an ideal machine that can potentially perform any algorithm on the basis of predetermined rules. The relevant feature is that the rules are written in a data structure (the "table of rules"), that can be easily evolved through genetic adaptive systems. In our application, a population of TMs modeling the evolution of prices is created and evolved in order to maximizing profit and reduce volatility.


Examples show Turing systems applied to S&P100 index, EUR/USD and GBP/JPY exchange rates.

S&P 500 index (click to enlarge)

EUR/USD exchange rate (click to enlarge)
GBP/JPY exchange rate (click to enlarge)

A genetic algorithm is used to search into hystorical data for recurring configurations, representing relations between prices or prices and technical indicators. Two kinds of patterns are considered, those that trigger long signals and those that trigger short ones. The mix of long and short patterns allows creating robust trading systems, that can reduce drawdowns in the market. The examples show the application of a pattern-based trading system to Air Liquide stock and S&P500 index. The systems have been trained on daily close prices from January 2003 to January 2007, than tested from February 2007 to October 2014. Notably, the systems have been able to avoid the market decline that followed the 2008 financial crisis.


Air Liquide (AI.PA) stock (click to enlarge)



S&P 500 index (click to enlarge)



Air Liquide (AI.PA) stock - signals (click to enlarge)
Next example shows a pattern system applied to a multiple Donchian Channel indicator. The genetic algorithm optimizes the parameters of 3 Donchian Channels. It also optimizes a table of patterns describing the position of price in relation to Donchian min, max and average lines.  

EUR/USD 1 hour exchange rate (click to enlarge)




Assuming that asset price movements can be expressed by a periodic function, this research aims to predict future movements using numerical methods applied to a packet of sinusoids. Inspired by research from Jean Baptiste Fourier, who in early nineteenth demonstrated that any periodic function can be considered as the sum of an arbitrary number of sinusoidal functions (sine and cosine), this approach tries to decompose a complex function (such as the movement of prices) in a series of simple functions using numerical methods. In this application, a population of sinusoids is used to generate buy and sell signals in the training set range. The population evolves until it expresses the "package" of curves that best fits the price series. Images show (in red) the equity lines obtained applying the trading system to the GBP/JPY and EUR/USD exchange rates.


GBP/JPY exchange rate (click to enlarge)
EUR/USD exchange rate (click to enlarge)
EUR/USD exchange rate (click to enlarge)

Some asset classes show, in historical price series, an isomorphism of scale typical of fractal geometry. This line of research transposes the price patterns on different time scales, trying to obtain a profit in short-term overnight trading.

A genetic algorithm is used to define both the pattern and the time scale. The image shows: the trend of USD/JPY exchange rate, the trend of a fractal time series (shift) and the equity line obtained using the fractal as an indicator for trading.


USD/JPY exchange rate (click to enlarge)