31.07.2021 Views

Ultimate Algorithmic Trading System

Using automated systems for trading in stock markets

Using automated systems for trading in stock markets

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

For generation = 1 To 100 ' total generations

For i = 0 To 5 'Six Chromos

FObj(i) = 0

For j = 0 To 3 ' Four Genes

'Calculate each expression in equation and accumulate

If j = 0 Then FObj(i) = Cells(3, 3) * chromo(i, j)

If j = 1 Then FObj(i) = FObj(i) + Cells(3, 4)

* chromo(i, j)

If j = 2 Then FObj(i) = FObj(i) + Cells(3, 5)

* chromo(i, j)

If j = 3 Then ' Test the summation against 40

FObj(i)=Abs((FObj(i)+Cells(3, 6)*chromo(i,j))

-Cells(3,7))

'if summation = 40 then solution found

If (FObj(i) = 0) Then foundSolution = i

End If

Next j

Next i

If we rank the chromosomes in order of fitness, then we would have the following:

■ Selection

Chromosome(2) = 64—closest to the solution (24 away)

Chromosome(3) = 90—second closest (50 away)

Chromosome(5) = 93

Chromosome(1) = 94

Chromosome(0) = 111

Chromosome(4) = 164

Now that we have our initial population and the respective chromosome fitness, we

can select the chromosomes that should be carried forward and used for reproduction

and mutation. It’s easy to see that the top four ranking chromosomes should be

selected because they are closer to our solution than the last two (the absolute

difference between the chromosome fit score and 40, our solution, is smaller).

However, the computer makes the decisions and it makes its selection based on

probabilities. This task is accomplished by converting each chromosome’s fitness in

terms of probability. We can’t make the selection decision for the computer, but

we can make sure the computer understands that some chromosomes are more fit

than others. If you remember probabilities from an old math or stat class, you know

the basic premise: Rolling a dice once results in one out of six potential outcomes.

233

GENETIC OPTIMIZATION, WALK FORWARD

www.rasabourse.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!