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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

102

COMPLETE TRADING ALGORITHMS

previously derived were for illustration purposes only. These tests simply provided

evidence that these algorithms have a technical edge. A new set of tests have to be

set up with our new portfolio across the four best performing algorithms. Also, we

need to come up with a set of parameters for each algorithm that will hopefully stand

the test of time. The test of time can be accomplished by utilizing out-of-sample

(OOS) data. OOS data is a segment of historical data that the algorithms did not see

during their developmental periods. The algorithms can be optimized on in-sample

data (IS) and the ‘‘optimal’’ parameter sets can then be applied to data that has not

yet been seen. The ratio between OOS and IS is a subject of much debate. Some

believe you should give the algorithm more data (IS) to be trained on in hopes that

the parameters will reflect more diverse market conditions. Others feel that a longer

walk-forward (OOS) test will demonstrate an algorithm’s true robustness. I don’t

believe there is a universal answer to this conundrum, but experience has shown that

a 1-to-3 ratio seems to work. The test period that we have been using is 15 years, so

using this ratio we come up with roughly five years of OOS and roughly 10 years IS.

Before we carry out these tests the subject of individual market optimization needs

to be brought up. I have never seen, in all my years of testing, a trading algorithm

utilizing different parameters on a market-by-market basis survive the test of time.

Even trading algorithms that just utilize different parameters on a sector-by-sector

basis haven’t been all that successful over the long run. All this optimizing simply

leads to over-curve-fitting. The trading systems that have stood the test of time have

one and only one parameter set for the entire portfolio. Now that that question

has been answered, what about periodical portfolio reoptimization? This is the idea

of optimizing an algorithm for the first five or so years and then carrying over for

the next year or two. At the end of the carryforward period, the parameters are

reoptimized over the new unseen data and then carried forward again. This form

of optimization uses a sliding IS data window. The results from the OOS data are

accurate, since the parameters were not trained on that data until after the fact. This

form of optimization is discussed extensively in Chapter 8.

Starting with the Donchian algorithm and our new portfolio, let’s optimize the

parameters from January 2000 through December 2009. Using the best parameters

set from this test, the algorithm will be tested across the remaining data, January

2010 through August 2015, to evaluate the robustness of the selection.

Table 3.13 shows the best results for the Donchian algorithm IS time period.

The parameter set that I chose was 98, 25, and $4,000. This was a top echelon set

that had a reasonable protective stop. In addition, the two length parameters were

located on a plateau—they were surrounded by similar values.

Now the real test begins. A diversified portfolio has been chosen as well as a

seemingly robust parameter set. Let’s walk this algorithm forward and test it across

the OOS time frame (January 2010 through August 2015). Table 3.14 exposes a

seeming act of futility.

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!