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.

TABLE 3.17

Results for the Donchian Algorithm when Walked Forward across an

Out-of-Sample (OOS) Time Period

Name

Net

Profit

CAR

Max.

Sys

DD

Profit

Factor

Ulcer

Index

#

Trades

Avg

P/L

Avg

Bars

Held

%

Winners

<Portfolio> −31803 −0.58 −222494.3 0.91 11.93 158 −201.28 56.15 30

AD0_E0B −2570 −0.05 −26410 0.91 1.64 16 −160.62 64.56 38

C20_E0B −8500 −0.15 −26325 0.71 1.73 20 −425 53.85 30

CL20_E0B −14060 −0.25 −58490 0.78 3.36 21 −669.52 40.95 29

CU0_E0B 16888 0.3 −39763 1.62 2.17 14 1206.25 67.57 36

HG20_E0B −25763 −0.46 −38750 0.56 2.47 19 −1355.92 45.26 26

KW20_E0B 8525 0.15 −15063 1.4 0.59 17 501.47 65.71 41

RB0_E0B −29267 −0.53 −79688 0.7 4.51 24 −1219.48 36.63 13

SB20_E0B 15185 0.27 −19315 2.07 1.28 11 1380.44 94.27 36

TY0_E0B 7760 0.14 −9334 1.46 0.49 16 484.99 65.38 38

small diversified portfolio. We did everything humanly possible to make these trendfollowing

systems work: algorithm selection, optimization, and portfolio selection.

What if we performed a more frequent periodic reoptimization? We saw the best

parameter set shifting from just five years ago. This shift may be attributable to the

disappearance of the pit session and the adoption of purely electronic markets. Who

knows why, but the fact remains that the commodity markets have had a fundamental

shift. Indicators such as the ones we have experimented with are adaptive by nature;

they change based on market activity and/or volatility. Theoretically, they should

be able to keep up with the evolution of the markets. In practice, this was not

the case.

AmiBroker has a walk-forward backtesting capability—meaning we can periodically

reoptimize parameters throughout a historic backtest. I discuss this optimization

method in great detail in Chapter 8. After this chapter, if you like, you can skip to

Chapter 8 to help you understand exactly what is going on here. Figure 3.4 illustrates

the basic concept of walk-forward testing. Basically it involves two primary steps:

1. Backtest and derive—backtest and extract the best parameter set based on some

criteria. It could be profit, drawdown, profit-to-drawdown ratio, etc.

2. Walk forward—take the parameter sets and apply them forward in time on data

not used in the backtest. Do this on a periodic basis.

In this example, the Bollinger Band algorithm will be reoptimized annually based

on the best-performing parameters for the prior four years. Keep in mind that we

are not cheating, as only the OOS (out-of-sample) data will be used to calculate

performance metrics. Let’s see if this method can turn around the trend of this

trend-following method. Figure 3.4 shows the process of walking forward.

105

COMPLETE TRADING ALGORITHMS

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!