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.

A loop is used to flow through each trade history and keep track of the maximum

and minimum values stored in the third element of the startTradeTuple (max

drawdown of each history).

Twenty bins will be used in this example to store the individual drawdown values.

The bin size is calculated by dividing the range of drawdowns by 20. The size of

the bin is stored in the variable binInc (bin increment). Each bin is constructed by

storing each bin’s boundary values in a list of tuples named binTuple. Each binTuple

contains three elements: binNumber, binBottom, and binTop. The boundary values

are calculated by starting at the smallest max drawdown of the histories (bottom of the

first bin) and adding the bin size to get the top of the first bin. The next bin’s bottom

boundary becomes the prior bin’s top and its top is calculated by adding the binInc.

This process is repeated until all 20 bin tuples are filled up with the correct values.

numBins = 20

binTuple = list()

binInc = (maxDD - minDD)/20.0

binBot = minDD

for y in range(0,numBins):

binTop = binBot + binInc

binTuple += ((y,binBot,binTop),)

print(binTuple[y][1],' ',binTuple[y][2])

binBot = binTop + y

Once the bins are constructed all the different histories’ max drawdowns are

distributed into them. This is accomplished by comparing the max drawdown with

each bin’s top and bottom boundaries. If the drawdown value falls between the two

boundaries, it is then placed into that bin. A blank list of bins is initially created.

bins = list()

bins[:] = []

for x in range(0,numBins):

bins.append(0)

The different histories are looped through and are placed into the different bins.

Well, not really, just the frequencies of the drawdowns are stored.

267

GENETIC OPTIMIZATION, WALK FORWARD

for x in range(0,len(startTradeTuple)):

for y in range(0,numBins):

tempDD = startTradeTuple[x][2]

tempBot = binTuple[y][1]

tempTop = binTuple[y][2]

if (tempDD >= binTuple[y][1] and tempDD <

binTuple[y][2]):

bins[y] += 1

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!