Home Blog Genetic Algorithms for Forex trading, part 1 of ??
 

So you want to use Genetic algorithms to do Forex trading, eh? :) Where should we start?  I'm going to use the specifics of JGAP (since that is the platform I've picked for my development) but the concepts should work with any genetic structure.

Let's start at the very beginning:  what exactly is the basis of what we are trying to implement? Is it the case that:

  1. we have a specific trading system or set of indicators that we think will do the trick when tweaked just so?  In this case the goal is to evolve a system with optimal parameters.
  2. we don't really have a specific system in mind.  We would then have a completely naive system, which starts from a large set of indicators and builds its own trading methods.

The first case, that of a specific trading system which is to be optimized, is the simpler case. Let's plan a Chromosome for a trivial trading system.  Define the trading system Genes as:

  1. a Long position is entered when a shorter-duration moving average crosses above a longer-duration MA, AND
  2. RSI rises from below a certain threshold to above a certain threshold
  3. No short positions will be taken
  4. position is closed when a fixed number of pips are gained, OR
  5. position is closed when a fixed number of pips are lost from the maximum advancement of the position (a trailing stop)

Gene 1 implements the cross of moving averages.  How many variables can we extract from that operation?

 
Component
Variables
shorter moving average bar length
  type (simple, weighted, exponentially smoothed)
longer moving average bar length
  type (simple, weighted, exponentially smoothed)

Really, it seems as though this should be something that is evolved on on its own. For a system of sufficient complexity the combinatorial expolsion of possibilities means that it would take much longer to find an optimal solution for any single gene within the whole.  So let's split this task out into a separate Chromosome.

Let's define the Moving Average Chromosome as having the four genes above.

Indicator variable range
ShorterMA bar length 5-15
Moving Average Chromosome
  Type simple, weighted, Smoothed EMA
LongerMA bar length 16-30
  type simple, weighted, Smoothed EM

Evolution of this should be tested by many runs through the Open Forex Platform backtesting framework.

But what is the fitness function? See The next post for that!  :)

Blog Navigation

The Latest

Scala on .NET

Posted by Eric Somdahl in Blog Entries

Towers of Hanoi in Scala

Posted by Eric Somdahl in Uncategorized
Joomla Templates by Joomlashack