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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Converting Fitness in Terms of Slice Size—Using VBA Excel

'fitness in terms slice size

For l = 0 To 5 'calculate for each of the six chromos

Next l

Fitness(l) = 1 / (1 + FObj(l))

Now that fitness has been redefined in terms of the size of the slice on the

dartboard, we can now calculate the probability of each slice being hit. First off,

let’s calculate the total size of all slices:

0.01389 + 0.01812 + 0.04000 + 0.01961 + 0.00800 + 0.01852 = 0.11814

The dartboard has a total size of 0.11814 units. Don’t worry about the units

because they are not important. Now that we know the size of the chromosomes’

respective slices and we know the total size of the dartboard, we can easily calculate

the probability of a dart hitting the individual slices. This is accomplished by

dividing the size of each chromosome slice by the total size. The probability of each

chromosome slice being hit with a blindfolded monkey are:

Chromosome (0) =0.0139∕0.1182 = 0.1175

Chromosome (1) =0.0182∕0.1182 = 0.1538

Chromosome (2) =0.0400∕0.1182 = 0.3384

Chromosome (3) =0.0196∕0.1182 = 0.1659

Chromosome (4) =0.0080∕0.1182 = 0.0677

Chromosome (5) =0.0185∕0.1182 = 0.1567

Calculate Probability of Being Hit by Dart—Using VBA Excel

'calculate chromo probability of being hit by dart

'accumulate probabilities and store in bins

cumProb = 0#

For l = 0 To 5 'this is a lower case l not a 1

Next l

chromoProb(l) = Fitness(l) / totalFitness

cumProb = cumProb + chromoProb(l)

chromoProbBin(l) = cumProb

Notice how the chromosome that was closest to our solution has a higher

probability of being hit by a dart. Chromosome (2) covers nearly 34 percent of the

dartboard.

The next thing the computer needs to do is construct the dartboard. The pie chart

in Figure 8.3 is a graphical representation of how the computer would internally

construct a dartboard with varying slice or sector sizes.

235

GENETIC OPTIMIZATION, WALK FORWARD

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!