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.

roulette(i) = Rnd(1#)

If roulette(i) <= crossRate Then

crossArr(i) = 1

End If

Next i

crossCnt = 0

For i = 0 To 5

Next i

'parentsList is a simple class

'similar to a point class with 2 coordinates

'total of six possible matchings

parentsList(i).mom = 999

parentsList(i).dad = 999

If crossArr(i) <> 0 Then

crossCnt = crossCnt + 1

'found mom but not dad - yet

'store mom in parentsList(i)

parentsList(i).mom = i

foundMate = False

cindex = i

Do While Not (foundMate)

Loop

End If

cindex = cindex + 1

If cindex > 5 Then cindex = 0

If crossArr(cindex) <> 0 Then

'found dad - store dad in parentsList(i)

End If

parentsList(i).dad = cindex

foundMate = True

In nature, a child will receive genetic material or traits from both parents. Some

children will receive more traits from the father than the mother, and vice versa.

How is this determined? In nature, who knows, but inside a computer, we can

discriminate how much the father and mother will contribute to the offspring.

Here again, an RNG saves the day. Each chromosome holds four different genes

(numbers), so we need to know how many of the four numbers will be passed on

by the father and mother to the new offspring. This is accomplished by randomly

calculating the split point where the numbers will be taken from both parents. In

other words, if the split equals two, then the mother chromosome will contribute her

first two numbers and the father chromosome will contribute his last two numbers.

There are four genes in each chromosome, so the random number generator will

generate a number between one and four. Figure 8.4 shows how the sharing of

genetic material is accomplished when the split point is one.

239

GENETIC OPTIMIZATION, WALK FORWARD

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!