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.

Here are the various calculations that are used to determine the total number of bars

per run, in-sample number of bars, and out-of-sample number of bars.

TotalBarsPerRun—Total number of bars / (Walk-forward runs * Out-ofsample

% + In-sample %). In our example test, there were a total of 3415

bars, 10 walk-forward runs, 20 OOS%, and 80 percent in-sample. WFO uses

bars in place of days to calculate the walk-forward window lengths.

TotalBarsPerRun = 3415 / (10 * 0.2 + 0.8) = 1219

InSampleBarsPerRun – TotalBarsPerRun * In-sample%

InSampleBarsPerRun = 1219 * 0.8 = 975

OutOfSampleBarsPerRun – TotalBarsPerRun * Out-of-sample%

OutOfSampleBarsPerRun = 3414 * 0.2 = 244

The first interval analyzes the first 975 bars of data and determines the best

parameter set and then carries that set on unseen data for 244 bars. The second test

starts on bar 976 and ends on 1950 (976 + 974) and then walks forward 244 more

days. Figure 8.7 illustrates this process by showing how four years are used to decide

the best parameters using hindsight and then how those parameters are applied to

unseen data the following year.

The WFO produces a WFA report that determines the usefulness of applying this

type of optimization to this particular trading algorithm. Before showing the contents

of this report let’s create a benchmark parameter set and compare those results

with those produced by the WFO. A benchmark can be created by using a fixed

parameter set throughout the entire test time period. This is easily accomplished by

setting the four parameters to the following values:

xLongEntryLen = 40, xLongExitLen = 20, xShortEntryLen = 40,

xShortExitLen = 20

In addition to making the parameters static notice that the system was also made

symmetrical; the buy-side parameters are the same as the sell-side parameters. This

particular parameter set did perform better over the walk-forward optimization as

it produced almost $17,000, whereas the WFO produced nearly $10,000 in profit.

253

GENETIC OPTIMIZATION, WALK FORWARD

2001 2002 2003 2004 2005

2002 2003 2004 2005 2006

2003 2004 2005 2006 2007

2004 2005 2006 2007 2008

FIGURE 8.7

How four years of hindsight are used to predict unseen data for the following year.

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!