The Ultimate Algorithmic Trading System Toolbox + Website - George Pruitt - E-Book

The Ultimate Algorithmic Trading System Toolbox + Website E-Book

George Pruitt

0,0
60,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

The accessible, beneficial guide to developing algorithmic trading solutions The Ultimate Algorithmic Trading System Toolbox is the complete package savvy investors have been looking for. An integration of explanation and tutorial, this guide takes you from utter novice to out-the-door trading solution as you learn the tools and techniques of the trade. You'll explore the broad spectrum of today's technological offerings, and use several to develop trading ideas using the provided source code and the author's own library, and get practical advice on popular software packages including TradeStation, TradersStudio, MultiCharts, Excel, and more. You'll stop making repetitive mistakes as you learn to recognize which paths you should not go down, and you'll discover that you don't need to be a programmer to take advantage of the latest technology. The companion website provides up-to-date TradeStation code, Excel spreadsheets, and instructional video, and gives you access to the author himself to help you interpret and implement the included algorithms. Algorithmic system trading isn't really all that new, but the technology that lets you program, evaluate, and implement trading ideas is rapidly evolving. This book helps you take advantage of these new capabilities to develop the trading solution you've been looking for. * Exploit trading technology without a computer science degree * Evaluate different trading systems' strengths and weaknesses * Stop making the same trading mistakes over and over again * Develop a complete trading solution using provided source code and libraries New technology has enabled the average trader to easily implement their ideas at very low cost, breathing new life into systems that were once not viable. If you're ready to take advantage of the new trading environment but don't know where to start, The Ultimate Algorithmic Trading System Toolbox will help you get on board quickly and easily.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 525

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Series Page

Title Page

Copyright

About The Author

Introduction to The Ultimate Algorithmic Trading Systems ToolBox

Chapter 1: Introduction to Trading: Algorithm Development

What Is an Algorithm?

How to Get My Trading Idea into Pseudocode

Summary

Chapter 2: Stochastics and Averages and RSI! Oh, My!

Oscillators

Price-Based Indicators

Summary

Chapter 3: Complete Trading Algorithms

Trend-Trading Battle Royale

Portfolio Composition

Multi-Algorithm Strategy (MAS)

Summary

Chapter 4: Introduction to AmiBroker's AFL

Quick Start

Price Bar Interface

AFL Array Programming

Syntax

AFL Wizard

AmiBroker Loop Programming

Summary

Chapter 5: Using Microsoft Excel to Backtest Your Algorithm

VBA Functions and Subroutines

Data

Software Structure

Programming Environment

Summary

Chapter 6: Using Python to Backtest Your Algorithm

Why Python?

Python Installation

PSB Installation

PSB Structure

Getting Down to Business

Summary

Chapter 7: An Introduction to EasyLanguage

TradeStation IDE

Syntax

Samples of EasyLanguage

Summary

Chapter 8: Genetic Optimization, Walk Forward, and Monte Carlo Start Trade Analysis

Utilizing TradeStation and AmiBroker

Computers, Evolution, and Problem Solving

Population

Initial Population Setup Using VBA Excel

Testing Fitness of Chromosomes Using VBA Excel

Selection

Reproduction

Mutation

Using Genetic Algorithms in Trading System Development

Preventing Over-Curve-Fitting

Walk-Forward Optimizer: Is It Worth the Extra Work and Time?

Monte Carlo Analysis

Start Trade Drawdown

Summary

Chapter 9: An Introduction to Portfolio Maestro, Money Management, and Portfolio Analysis

Fixed Fractional

Portfolio Maestro

Summary

Appendix A: AmiBroker

Keywords

Flow Control Structures

Functions

Utilizing Exploration for Debugging

Position Sizing in Futures Mode

Appendix B: Excel System Backtester

Data Arrays

Keywords

Functions and Subroutines

Appendix C: Python System Backtester

Data Arrays or Lists

Keywords and Identifiers

Classes

Indicator Classes and Functions

Python-Specific Keywords

Appendix D: TradeStation and EasyLanguage

Importing ELD file from Book Website

Keywords and Functions

Sample Algorithm Codes

Appendix E

About the Companion Website

Index

End User License Agreement

Pages

ii

iv

ix

x

xi

xii

xiii

xiv

xv

xvi

xvii

xviii

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

25

26

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

323

324

325

326

327

328

329

330

331

332

333

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

Guide

Cover

Table of Contents

Begin Reading

List of Illustrations

Chapter 1: Introduction to Trading: Algorithm Development

Figure 1.1 Examples of strength differences between pivot high points on daily bars.

Figure 1.2 A depiction of the variable-bar sequence described by the long entry signal.

Figure 1.3 An FSM that models the workings of a combination lock.

Figure 1.4 An FSM that models the pivot-point long-entry algorithm described in this chapter.

Figure 1.5 A very simple FC.

Figure 1.6 An FC of a trading algorithm.

Chapter 2: Stochastics and Averages and RSI! Oh, My!

Figure 2.1 Examples of directional movement.

Figure 2.2 ADX as a trend detector.

Figure 2.3 Wilder's directional movement algorithm.

Figure 2.4 Example of a trade generated by RSI.

Figure 2.5 Flowchart diagram of RSI trading algorithm.

Figure 2.6 Example of RSI divergence.

Figure 2.7 Example of FSM modeling RSI Swing Failure.

Figure 2.8 Chart showing trade signals from stochastic crossover algorithm.

Figure 2.9 The flowchart for an algorithm using a stochastic oscillator crossover as an entry signal.

Figure 2.10 Trades generated by the CCI algorithm when it crosses above 100 and below −100.

Figure 2.11 The CCI system detecting a downturn in the Eurocurrency.

Figure 2.12 Histogram pivot points can initiate trade signals.

Figure 2.13 Three different 20-day moving averages.

Figure 2.14 A 60-day, two-SD Bollinger Band on crude oil.

Figure 2.15 Keltner Channels and Bollinger Bands applied to the same data.

Figure 2.16 Bollinger Band optimization.

Figure 2.17 Keltner Channel optimization.

Chapter 3: Complete Trading Algorithms

Figure 3.1 Turtle trading algorithm flowchart.

Figure 3.2 A three-dimensional contour chart of Bollinger performance across a subset of the parameters that were originally optimized.

Figure 3.3 A snapshot of a portion of the current portfolio correlation matrix.

Figure 3.4 Walk-forward testing begins with a backtest used to derive the desired parameter. Then, it applies that parameter going forward.

Figure 3.5 AmiBroker's walk-forward optimizer in action.

Figure 3.6 Parameters selected to carry forward for the following year.

Figure 3.7 Performance of the WFO of the Bollinger Band system.

Figure 3.8 Equity curve that reflects a pattern system.

Figure 3.9 Mini-Russell day trading system using a narrow range day. It initially puts on two contracts, pulling the first one off after a certain profit is reached and leaving the second to run its course.

Chapter 4: Introduction to AmiBroker's AFL

Figure 4.1 Launching AmiBroker's AFL editor.

Figure 4.2 The AmiBroker Editor window.

Figure 4.3 The AFL Editor's auto-completion tool.

Figure 4.4 AFL Editor function helper.

Figure 4.5 The AFL Check icon.

Figure 4.6 An error warning.

Figure 4.7 The “Send to Analysis” window icon.

Figure 4.8 Apply the algorithm to the current data.

Figure 4.9 Set the parameters for the backtest.

Figure 4.10 Set Futures mode.

Figure 4.11 The trade-by-trade report.

Figure 4.12 The portfolio results.

Figure 4.13 A 3D optimization chart.

Figure 4.14 The AFL Code Wizard button.

Figure 4.15 A new AFL Code Wizard window.

Figure 4.16 Add item in AFL Code Wizard.

Figure 4.17 The AFL Code Wizard “Edit Rule” dropdown list.

Figure 4.18 Changing the parameters in the “Edit Rule” pane.

Figure 4.19 Click the exclamation point to send your request to AmiBroker.

Figure 4.20 Automatic Analysis dialog box.

Figure 4.21 Sample loop programming code.

Chapter 5: Using Microsoft Excel to Backtest Your Algorithm

Figure 5.1 Once you define the Bollinger Band routine, you can easily incorporate it into trading.

Figure 5.2 The structure of the backtesting software.

Figure 5.3 A typical Excel data worksheet.

Figure 5.4 The DataMaster worksheet can help you store the values of your commodities and futures contracts.

Figure 5.5 The Results worksheet lists multiple trades and their associated performance metrics.

Figure 5.6 The EquityStream worksheet has a button that launches a macro to create a chart that plots the cumulative daily equity and drawdown.

Figure 5.7 Customize your Excel ribbon. Make sure you check the box next to the Developer tab option.

Figure 5.8 The Developer tab in Microsoft Excel.

Figure 5.9 The Visual Basic Editor (VBE) in Microsoft Excel.

Figure 5.10 Comment text in VBA code is written in gray. It is also indicated by the single quote at the beginning of each line.

Figure 5.11 This is where the VBA comments end and the actual source code begins.

Figure 5.12 This error message appears if your algorithm does not have enough ramp-up data.

Figure 5.13 This tiny snippet of code contains five arguments, which are all necessary for the Trade subroutine.

Chapter 6: Using Python to Backtest Your Algorithm

Figure 6.1 NotePad++'s collapsible text feature.

Figure 6.2 A Python syntax error message.

Figure 6.3 In this case, the syntax error was the result of confusion between the assignment operator (=) and the comparison operator (==). Python highlights the problematic code.

Figure 6.4 A Python run-time error resulting from using parentheses instead of square brackets.

Chapter 7: An Introduction to EasyLanguage

Figure 7.1 The TradeStation home screen.

Figure 7.2 TradeStation's trading apps.

Figure 7.3 The initial screen of the TradeStation Development Environment.

Figure 7.4 The EasyLanguage editor in the TradeStation Development Environment.

Figure 7.5 The algorithm with a single, complete portion of the strategy marked.

Figure 7.6 The EasyLanguage editor monitors what you are typing and provides likely functions.

Figure 7.7 How to apply a strategy to your chart.

Figure 7.8 A reversion analysis strategy shown on a chart.

Figure 7.9 How to change the inputs and adjust your strategy.

Figure 7.10 The four input variables to adjust the mean reversion strategy.

Figure 7.11 A message confirming that your code was verified and will be recalculated based on the new inputs.

Figure 7.12 TradeStation lists any syntax errors it finds during verification in the bottom pane of the screen. The line number of the error is provided so you can easily find it in your code.

Figure 7.13 The EasyLanguage editor can display line numbers to make it easy to navigate your code.

Figure 7.14 To create a new project using your strategy, select Project from the File menu.

Figure 7.15 How to add an existing strategy to a new project.

Figure 7.16 All dependencies and functions are nested inside their strategy algorithm.

Chapter 8: Genetic Optimization, Walk Forward, and Monte Carlo Start Trade Analysis

Figure 8.1 Iteration growth rate of five parameters.

Figure 8.2 An illustration of our chromosomes with different genetic values.

Figure 8.3 Chromosome dartboard.

Figure 8.4 At split 1 the genes that will be passed onto the offspring by the father and the mother.

Figure 8.5 Robust parameter sets are found on a level plateau.

Figure 8.6 A graphic representation of how the walk-forward analysis (WFA) rolls forward.

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

Figure 8.8 The Cluster WFO results matrix.

Figure 8.9 AmiBroker Monte Carlo settings dialog.

Figure 8.10 Monte Carlo Straw Broom chart of multiple randomized equity curves.

Chapter 9: An Introduction to Portfolio Maestro, Money Management, and Portfolio Analysis

Figure 9.1 TradeStation's Portfolio Maestro (PM) launch window.

Figure 9.2 Add a strategy to your strategy group.

Figure 9.3 The Turtle 55 strategy is now in your strategies window.

Figure 9.4 Add a symbol by clicking the Symbol Lists tab (indicated by Arrow 1), then clicking on Add Symbol List (shown with Arrow 2).

Figure 9.5 After selecting the UGTATS list, it will appear in your symbol list window.

Figure 9.6 The UGTATS markets and their corresponding symbols.

Figure 9.7 A list of available strategy groups, including MyFirstStrategyGroup, which we are using for this exercise.

Figure 9.8 After selecting MyFirstStrategyGroup, you will see it in MyFirstPortfolio. In the expanded view, you can see the strategies and symbols that are part of your group.

Figure 9.9 How to adjust the settings for a strategy group. Arrow 1 indicates the Manage Strategy Group button. Arrow 2 highlights the Strategy Group Settings button. Arrow 3 points to the controls that change the commission and slippage inputs.

Figure 9.10 As you prepare to backtest your portfolio, ensure the settings are correct. Begin by clicking the Backtest Portfolio button (marked 1 in the figure). Then, check the initial capital, test period, and backtest type in the appropriate fields (marked with 2). When everything looks good, click the Perform Backtest button (number 3 in the figure).

Figure 9.11 A backtest performance report.

Figure 9.12 The Trade Analysis window displays trading statistics. To get to this screen, click the Trade Analysis tab (marked 1). The View/Hide Symbols button (marked 2) reveals the performance metric for every market in your portfolio (item 3).

Figure 9.13 An equity curve chart that shows the maximum drawdown.

Figure 9.14 The Total P/L option displays individual profit and loss data for every market in the portfolio.

Figure 9.15 The Returns and Equity tab displays the portfolio's maximum drawdown in this case.

Figure 9.16 The arrows indicate the parameters that you can change from the Money Management window. For now, keep the ATR lookback set to 10 and the round quantity set to 1.

Figure 9.17 The equity curve of the backtest reveals a profit of nearly $1 million.

Figure 9.18 Profit and drawdown are directly proportional to position size. As your position size changes, so do your commissions and profits and losses.

Figure 9.19 Under Portfolio Settings (marked as 1), go to the Portfolio Stops tab (marked as 2) and set the stop strategy of your choosing. Under the dropdown menu, there is a description of how the selected strategy will impact your portfolio (marked as 3).

Figure 9.20 To set the portfolio stop loss, you can adjust the loss target percentage (marked as 1), loss target (marked as 2), and period (marked as 3).

Figure 9.21 To set the portfolio profit target, you can adjust the period, profit target percentage, and profit target. These options align with those in the stop loss tab.

Figure 9.22 The portfolio profit target and stop loss now appear as strategies in your portfolio.

Figure 9.23 At the bottom of your screen, you should see the portfolio stop option.

Figure 9.24 The equity curve of the portfolio once the stops have been added.

List of Tables

Chapter 2: Stochastics and Averages and RSI! Oh, My!

Table 2.1 Performance of Directional Movement Algorithm

Table 2.2 Performance of RSI Algorithm

Table 2.3 Performance of RSI Failure Swing Algorithm

Table 2.4 Performance of Stochastic Algorithm

Table 2.5 Performance of CCI algorithm

Table 2.6 Performance of CCI Algorithm as Coincident Indicator

Table 2.7 Examples of Trades Generated by Stochastics

Table 2.8 Performance of Bollinger Band Algorithm Version 1

Table 2.9 Performance of Bollinger Band Algorithm Version 2

Table 2.10 Bollinger Benchmark versus Keltner Challengers

Table 2.11 Best Parameter Sets of Bollinger Bands Algorithm

Table 2.12 Best Parameter Sets of Keltner Channel Algorithm

Chapter 3: Complete Trading Algorithms

Table 3.1 Turtle System 1 without LTLF for the Sample Portfolio

Table 3.2 Turtle System 2 for the Sample Portfolio

Table 3.3 Turtle System 1 with LTLF for the Sample Portfolio

Table 3.4 Tandem Performance of Turtle System 1 with LTLF and Turtle System 2 for the Sample Portfolio

Table 3.5 Single Moving Average (SMA) Crossover Algorithm

Table 3.6 Double Moving Average (DMA) Crossover Algorithm

Table 3.7 Triple Moving Average (TMA) Crossover Algorithm

Table 3.8 Donchian Channel Breakout for Different Donchian Lengths

Table 3.9 Bollinger Band Breakout

Table 3.10 Comparison of Parameters for Algorithms Based on Different Strategies

Table 3.11 Top 10 Parameter Sets for Each Algorithm

Table 3.12 The Best Parameter Sets for Each Optimization

Table 3.13 The Best Results for the Donchian Algorithm for In-Sample Time Period

Table 3.14 Results for the Donchian Algorithm when Walked Forward across an Out-of-Sample (OOS) Time Period

Table 3.15 The Best Parameters for the Portfolio over the Out-Of-Sample (OOS) Time Period

Table 3.16 The Optimization of the Bollinger Algorithm for the In-Sample (IS) Time Period

Table 3.17 Results for the Donchian Algorithm when Walked Forward across an Out-of-Sample (OOS) Time Period

Chapter 7: An Introduction to EasyLanguage

Table 7.1 EasyLanguage Keywords and Abbreviations

Chapter 8: Genetic Optimization, Walk Forward, and Monte Carlo Start Trade Analysis

Table 8.1 Results from the Exhaustive Search Algorithm's Five Parameters

Table 8.2 Results from the Genetic Search Algorithm's Five Parameters

Table 8.3 In-Sample Testing TA2

Table 8.4 Out-of-Sample Testing

Table 8.5 WFA Report on TA2

Table 8.6 The Out-of-Sample (OOS) Report

Table 8.7 WFO Report Card TA3

Table 8.8 Distribution Statistics from Monte Carlo Simulations

Chapter 9: An Introduction to Portfolio Maestro, Money Management, and Portfolio Analysis

Table 9.1 Portfolio Trades without Stops

Table 9.2 Portfolio Trades with Stops in Place

The Wiley Trading series features books by traders who have survived the market's ever changing temperament and have prospered—some by reinventing systems, others by getting back to basics. Whether a novice trader, professional, or somewhere in between, these books will provide the advice and strategies needed to prosper today and well into the future. For more on this series, visit our website at www.WileyTrading.com.

Founded in 1807, John Wiley & Sons is the oldest independent publishing company in the United States. With offices in North America, Europe, Australia, and Asia, Wiley is globally committed to developing and marketing print and electronic products and services for our customers' professional and personal knowledge and understanding.

THE ULTIMATEALGORITHMICTRADING SYSTEMTOOLBOX+ Website

Using Today's Technology to HelpYou Become a Better Trader

George Pruitt

 

Copyright © 2016 by George Pruitt. All rights reserved.

Published by John Wiley & Sons, Inc., Hoboken, New Jersey.

Published simultaneously in Canada.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600, or on the Web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.

Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Cataloging-in-Publication Data:

Names: Pruitt, George, 1967- author.

Title: The ultimate algorithmic trading system toolbox + website : using today's technology to help you become a better trader/George Pruitt.

Description: Hoboken : Wiley, 2016. | Series: Wiley trading | Includes index.

Identifiers: LCCN 2016010889 (print) | LCCN 2016011196 (ebook) | ISBN 9781119096573 (hardback) | ISBN 9781119262961 (pdf) | ISBN 9781119262978 (epub)

Subjects: LCSH: Electronic trading of securities. | Investment analysis. | Futures. | BISAC: BUSINESS & ECONOMICS/Finance.

Classification: LCC HG4515.95 .P788 2016 (print) | LCC HG4515.95 (ebook) | DDC 332.640285/4678— dc23

LC record available at http://lccn.loc.gov/2016010889

Cover Design: Wiley

Cover Images: © agsandrew/Shutterstock

About The Author

It was March of 1989 as I drove my beat-up Dodge up Hillside Rd. in Hendersonville, NC. In an attempt to pay for my last semesters of college I was answering a classified ad that was looking to hire a computer programmer. As I drove up the thin drive I passed several houses and then through a gate attached to two large stone pillars. I stopped the car and looked down at the ad again to make sure I was at the right place. I proceeded down the country lane and the view opened up into a large meadow. At the end of the lane was a circular drive and large farm house. As I circled and went back down the road I thought to myself I must have the wrong address or directions. So I followed the small road back down the main highway and then to a small convenient store. Once there I asked myself again what type of business was this Futures Truth and if I should call and get directions or just simply forget about it. Curiosity and the need for money were too much so I used the store's pay phone and called the number once again.

“Hello—Futures Truth, may I help you?” a lady's voice answered.

“Yes, this is George Pruitt and I made an appointment for an interview but I can't seem to find your office.”

“Do you drive a red Dodge?” she asked.

“Yes I do. How did you know?”

“We saw you drive right by the office. When you come through the two stone pillars turn immediately to the left. Don't go all the way down the drive—that's the owner's house.”

So I follow the directions and find myself in front of a small house. I knock on the door and John Fisher opens and invites me in. We go through the normal Q and A for a job interview and he finally asks if I knew FORTRAN. My first college programming class was FORTRAN so I confidently answered, “Sure!”

He then asked me if I knew anything about the Futures market. I vaguely remembered the term from one of my economics classes and of course from the Eddie Murphy movie and answer him with the question, “You mean like Trading Places with Eddie Murphy?”

John Fisher said “Sort of like that—yes.”

He went on to explain how Futures Truth tried to determine market direction in the most widely traded futures contracts by using trading systems. The trading systems were programmed in FORTRAN and they needed help with the programming. In addition to trading they also published a newsletter in which they tracked publicly offered trading systems.

I asked, “Do people really buy these programs?”

John Fisher said yes and by that time an older gentlemen walked into the office and stated that he had spent thousands of dollars on these programs and was ultimately ripped off. John Hill stated this was the main reason he started Futures Truth. He wanted to bring truth to the trading system industry. Both Johns told me that most traders couldn't afford to validate the trading systems because of the cost of the computer equipment, data, and software. John Fisher pointed to the computer he was working on and asked, “How much do you think this Macintosh II cost?”

I answered him, “I am not that familiar with Macs but I know they aren't cheap.”

My mouth fell open when he said “$4,000 and we have three of them.” Remember this was way back in 1989 when computers were not cheap.

I was thinking to myself that they got ripped off because they could have got a much cheaper and better computer with the IBM PS/2. And what was up with using FORTRAN? Did they not know “C” was the new programming language of the 1990s? John Fisher chose the Apple Macintosh because of its easy-to-use graphical user interface (GUI) and FORTRAN because many traders and hobbyist programmers had knowledge of this language.

John Fisher also said that he and John Hill had developed what they considered the best testing platform, “Excalibur.” This platform could load decades of daily and intraday data and test any trading idea that could be defined in an algorithmic form. He also said the only thing that was missing was a charting application and that was where they also needed help.

I explained that I would be wrapping up my degree after summer and both Johns agreed that I could work part time in the evening until I graduated and then we could go from there.

Well that was 27 years ago and I did work part time until I graduated with a degree in computer science from the University of North Carolina at Asheville. The “Excalibur Chart” project turned into my senior project, which blew my professors away. Over the years I have worked with many trading firms in the development of trading algorithms and testing platforms. I have seen it all and have had the great pleasure to be educated by some of the greatest minds in the industry, including John Fisher, John Hill Sr. and John Hill Jr. Even with this experience and education the ultimate trading system still eludes me. As John Hill has stated many times, “A speculator who dies rich, dies before his time!” This may be true, but I have seen traders make millions, lose millions, and make millions again. The one thing they always do when they fail is get right back up, dust themselves off, and start searching for the next great trading algorithm.

Introduction to The Ultimate Algorithmic Trading Systems ToolBox

If you want to learn more about high-frequency trading utilizing special order placement/replacement algorithms such as Predatory trading, Pinging, Point of Presence, or Liquidity Rebates, then this book is not for you. However, if you want to learn about trading algorithms that help make a trading decision, trade size, money management, and the software used to create these algorithms, then you're in the right place.

This book is designed to teach trading algorithm development, testing, and optimization. Another goal is to expose the reader to multiple testing platforms and programming languages. Don't worry if you don't have a background in programming; this book will provide enough instruction to get you started in developing your own trading systems. Source code and instructions will be provided for TradeStation's EasyLanguage, AmiBroker's AFL, and my own Python and Excel testing engines. I chose these platforms because they give a nice overview of different scripting languages and trading platforms. Users of different testing/trading platforms may criticize my decision to use just these platforms, but the EasyLanguage source code that will be provided can be easily ported into Multi-Charts, and AmiBroker's unique and powerful platform provides a complete trading solution. My Python and Excel software, including all source code, are included on the associated website as well as the EasyLanguage and AFL source code for the other platforms. I didn't include the use of Python's scientific libraries, NumPy or SciPy, because I wanted to keep things as simple as possible. Also I used the bare-bones IDLE (Python's own simple Integrated Development Environment) to cut down on the learning curve—I wanted to get to the bare essentials of Python without muddying the water with a sophisticated IDE. Many successful Quants utilize R (a GNU project for statistical computing), but again to keep things simple I stuck with the easy-to-learn Python. The majority, if not all algorithms were tested utilizing commodity and futures data only. All the testing platforms in the book can be used to test stocks and ETFs, and all the included trading algorithms can be applied to these assets as well. Stock and ETF data is very simple to acquire. Getting commodity and futures data in an easily usable format is a little more difficult. Deep histories for commodity and futures can be acquired for as little as $100 from Pinnacle Data. I have used CSI data since the late 1980s and it is the data I used for a good portion of the testing carried out in the book. I would definitely take a look at Pinnacle and CSI data, especially if you wanted your database updated daily. If you are not familiar with Quandl, then you might want to take the time to do so. Quandl is a search engine for numerical data. I was pleasantly surprised to find a free continuous futures database (Wiki Continuous Futures) on Quandl. Keep in mind this data is free and is no way as good as premium data such as CSI and Pinnalce—it is missing multiple days and data points and the continuous data is simply created by concatenating data from individual contracts. The gaps between contracts are included, which cannot be utilized on any testing platform. In real life, a futures position is “rolled-over” from one contract to another by liquidating the front-month position and initiating the same position in the next contract. This “rollover” trade eliminates the gap. I have written a Python application that takes the Wiki Futures data and creates a back-adjusted continuous contract that can be imported into the Python and Excel System Back Tester software. Since I needed the data to do testing, I have also included a 10-plus-year ASCII back-adjusted futures database for 30-plus markets on the companion website. Directions on how to use the software and download futures data from Quandl are included along with the software.

The one thing I really wanted to include in this book was the “Holy Grail” of algorithmic trading systems. I have analyzed many algorithms that claimed to be the Grail, but after rigorous testing they failed to break even. So go ahead and check this off your list. Even though the “Holy Grail” will remain hidden you will find the following:

Twenty-seven years of experience working with non-programmers in the development of their own trading algorithms

The tools or building blocks that are used most often in the development cycle

The core trading models that make up the majority of publicly offered trading systems

The most important and simplest programming techniques to transform a non-quant into a not-so-non-quant

Simple examples and explanations of complex trading ideas such as Walk Forward and Genetic Optimization and Monte Carlo simulation

A complete toolbox to help algorithm development from idea to a finished tradable solution

The majority of successful trading algorithms utilize quantitative analysis (QA). QA is simply the application of mathematical formulae to a financial time series. This book will solely focus on this type of analysis in the design of trading algorithms. Fundamental analysis, which is used in many trading plans, will be used, too, but it will be reduced and simplified into a pure and easily digestible data format. Fundamental data is huge and diverse and in many cases market movement reacts to it in an unpredictable manner. A good example that I have dealt with for many years is the monthly unemployment report. At the time of the writing of this book unemployment has been on a downward trend, which is usually a bullish indicator for the stock market. However, with interest rates at the time being close to 0% the market could react opposite due to the fear of the Federal Reserve doing away with quantitative easing and raising rates. This type of fundamental analysis requires many different inputs and trying to reduce it down to something testable is nearly impossible.

Quantitative analysis focuses on just the data included in a chart. Price action and price translations are easily definable and therefore can be tested. The ability to test and evaluate a trading algorithm is a tremendous tool as it shows how a model can accurately map a market's behavior. If you can interpret a market's behavior, you can take advantage of its inefficiencies. If an algorithm has been capable of exploiting a market's inefficiencies on a historic basis, then there is a possibility it will do so in the future. This hope of future performance is the only leg an algorithmic trader has to stand upon. We all know historic performance is not necessarily an indicator of future results, but what else do we have? An algorithmic trader who quickly defines and tests his system and immediately takes a leap of faith because the historic performance looks great is doomed. Doesn't this contradict what I just said about historical performance being a system trader's only gauge of quality? A good trading algorithm not only demonstrates profitability but also robustness. Robustness is an expression of how well a trading system performs on diverse markets and diverse market conditions. An algorithm can be improved to a point where the trader can feel somewhat confident putting on those first few trades as well as continuing to put trades on after a losing streak. Improving an algorithm is not simply tweaking it until the historic results look utterly fantastic (aka curve fitting); it is taking the time to learn and work with tools that are designed to make a trading algorithm fail. That's the ultimate objective—making your trading algorithm fail before any money is put on the line. Remember the absence of failure is success and if your algorithm survives the brutal gauntlet of in depth analysis, then you know you might, just might have a winner.

This book starts out simple in Chapter 1 with the definition and examples of algorithms. The chapter is a little longwinded but I know that the inability to put a trading idea onto paper and then into pseudocode and finally actual computer code is the biggest stumbling block for traders who want to test their own trading ideas. All trading algorithms that are reducible to a set of instructions can be properly programmed using one of two different modeling methods or paradigms. These two paradigms, Finite State Machine and Flow Chart, are fully discussed and utilized to translate written descriptions first into diagrams and then into actual pseudocode. The diagrammatic approach as well as the simple pseudocode language used to formulate trading algorithms is introduced in this chapter. It doesn't matter how sophisticated your testing software is if you can't define a testable algorithm and this chapter shows you how to do so.

Chapter 2 may be a refresher for those who are familiar with the basic building blocks of trading algorithms, indicators; however, the chapter not only explains the logic behind the indicators but shows how they can be incorporated into complete entry and exit techniques. Diagrams and pseudocode are carried on through this chapter to aid in the understanding of each indicator, its purpose, and its place in a trading algorithm. In addition, the first look at indicator-based trading algorithm performance is presented as well.

Chapter 3 introduces complete trading algorithms and their associated historical performance. Most, if not all, testing was performed on historical commodity/futures data. This data gave rise to the concept of systematic trading more than 50 years ago. Now this doesn't mean the ideas aren't transferable to the stock market. In most cases they are. However, I stuck with commodity data because that is where my expertise lies. The complete pseudocode and actual computer code of these algorithms are revealed as well. The key metrics for determining algorithm robustness are explained and utilized in the evaluation of the algorithms' results.

Chapter 4 starts the section that highlights different testing/trading software platforms that can either be purchased or leased. AmiBroker is introduced in this chapter and the most important components of a trading platform are highlighted: integrated development environment and its associated scripting/programming language, individual market and portfolio testing, and algorithm performance metrics. These components are then highlighted again in Chapter 5 with VBA for Excel, Chapter 6 with Python, and finally Chapter 7 with TradeStation.

Chapter 8 delves into the concepts of Genetic and Walk Forward Optimization, Walk Forward Analysis, and Monte Carlo simulation. A genetic optimizer is built using VBA and used to help explain the ideas of synthesizing computers with biology. The core concepts of Genetic Algorithms, fitness, selection, reproduction, and mutation are fully explained and illustrated utilizing Excel. Artificial intelligence is here to stay in the study of trading algorithms and this chapter tries to pull back the veil of mystery and show how these tools should be used, and in some cases, must be used to develop that elusive robustness. Along these lines, Machine Learning has become a very highly discussed and somewhat controversial topic in today's trading. Also “Big Data” analysis has found its way to the front as well. These topics are highly advanced and I felt beyond the scope of this book. I can state I have worked with the algorithms that were derived with machine-only input and they have stood the test of time.

A trading algorithm must work over a diverse portfolio of markets before it can be sufficiently considered useful and robust. Chapter 9 utilizes the portfolio-level testing capabilities of TradeStation and AmiBroker to demonstrate different money and portfolio management techniques. The Fixed Fractional approach, by far the most popular, will be highlighted.

The complete source code for the Python System Back Tester is included on the website. Python is the new language of many a quant and the source shows how the language can be used to develop a simple, yet powerful, back tester. Important language concepts and syntax are used to open ASCII files, and import the data into a LIST data structure, create classes and modules, and loop through the entire database while applying a trading algorithm. All the parts of building a testing platform are revealed in the source code, including Monte Carlo and Start Trade Drawdown simulation.

Most traders have Microsoft Excel on their computers and the complete source for a more simplified version of the Python back tester using VBA is included on the website as well.

This book is a toolbox and a guide and touches upon many different facets of algorithmic trading. As with any toolbox it will take time and effort to apply the tools found within to replicate the trader's ideas in a form that not only can be tested and evaluated but fully implemented.