TEAMFLY Team-Fly ® Building Winning Trading Systems with TradeStation ™ 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 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 the 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 a list of available titles, please visit our Website at www.WileyFinance.com. Building Winning Trading Systems with TradeStation ™ George Pruitt John R. Hill FUTURES TRUTH John Wiley & Sons, Inc. Copyright © 2003 by George Pruitt and John R. Hill. 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-750-4470, 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, e-mail: permcoordinator@wiley.com. 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 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 also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. For more information about Wiley products, visit our web site at www.wiley.com. Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley & Sons, Inc. is aware of a claim, the product names appear in initial capital or all capital letters. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. Library of Congress Cataloging-in-Publication Data: Pruitt, George, 1967– Building winning trading systems with TradeStation ™ / George Pruitt, John R. Hill. p. cm. — (the Wiley trading series) Includes index. ISBN 0-471-21569-4 (cloth: alk. paper) 1. Investments—Data processing. 2. Stocks—Data processing. I. Hill, John R., 1926– II. Title. III. Series. HG4515.95.P78 2002 332.64'2'02855369—dc21 Printed in the United States of America 10987654321 To my loving wife and family. J. H. I would like to dedicate this book to Mary, Cliff, Butch, and Marilyn for their eternal courage and support. I would also like to thank my loving wife, Leslie and my patient and understanding children, Brandon and Emily. G. P. vii Contents Acknowledgments xi Introduction xiii Chapter 1 Fundamentals 1 What is EasyLanguage? 1 Variables and Data Types 2 Operators and Expressions 5 Precedence of Operators 6 TradeStation 2001i versus TradeStation 6.0 8 TradeStation 2000i 9 PowerEditor 9 A Simple Program 11 TradeStation StrategyBuilder 13 TradeStation 6.0 18 PowerEditor 18 A Simple Program 22 Conclusions 29 Chapter 2 EasyLanguage Program Structure 30 Structured Programming 30 Program Header 31 Calculation Module: MyRSIsystem 32 Conclusions 37 Chapter 3 Program Control Structures 39 Conditional Branching with If-Then 39 Conditional Branching with If-Then-Else 43 Repetitive Control Structures 48 For Loop 48 While Loop 50 Conclusions 51 Chapter 4 TradeStation Analysis Techniques 52 Indicators 52 PaintBar and ShowMe Studies 59 Functions 65 Strategies 70 Conclusions 75 Chapter 5 Measuring Trading System Performance and System Optimization 77 TradeStation’s Summary Report 78 Total Net Profit 81 Maximum Intraday Draw Down 82 Account Size Required and Return on Account 82 Average Trade 83 Maximum Consecutive Winners and Losers 84 Number of Trades and Average Number of Bars Per Trade 84 Average Winning and Losing Trade 84 Trades 85 Analysis 88 Graphs 93 Optimization 96 Conclusions 108 Chapter 6 Trading Strategies That Work (or The Big Damn Chapter on Trading Strategies) 109 The King Keltner Trading Strategy 111 King Keltner Pseudocode 112 King Keltner Program 112 King Keltner Summary 114 The Bollinger Bandit Trading Strategy 115 Bollinger Bandit Pseudocode 116 Bollinger Bandit Program 116 Bollinger Bandit Summary 118 The Thermostat Trading Strategy 119 Thermostat Pseudocode 121 viii Contents Thermostat Program 122 Thermostat Summary 123 The Dynamic Break Out II Strategy 126 Dynamic Break Out II Pseudocode 127 Dynamic Break Out II Program 128 Dynamic Break Out II Summary 130 The Super Combo Day Trading Strategy 134 Super Combo Daily Data Bar Calculation Pseudocode 139 Super Combo Code 143 Super Combo Summary 146 The Ghost Trader Trading Strategy 149 Ghost System Code 150 Real System Code 151 The Money Manager Trading Stragegy 153 The Money Manager Code 154 Conclusions 156 Chapter 7 Debugging and OutPut 157 Logical Versus Syntax Errors 158 Debugging with the Print Statement and Print Log 158 Table Creator 160 Conclusions 166 Chapter 8 TradeStation as a Research Tool 168 Commitment of Traders Report 168 Day of Week Analysis 176 Open to Close and Open to Open Relationships 176 Day of Week Volatility Analysis 177 Time of Day Analysis 183 Pattern Recognition 188 Intermarket Analysis 192 Conclusions 193 Chapter 9 Using TradeStation’s Percent Change Charts to Track Relative Performance 194 Working with Percent Change Charts 196 Conclusions 200 Chapter 10 Options 201 Option Basics 202 Listed Options 204 Nomenclature and Terminology 205 Long and Short 206 Contents ix [...]... be of the Numeric data type, since we initialized them with numbers Variable names should be self-descriptive and long enough to be meaningful Which of the following is more self-explanatory? mySum = High+Low+Close; myAvg = mySum/3; BuyPt = Close + myAvg; or k = High + Low + Close; j = k/3; l = Close+j; 4 Building Winning Trading Systems with TradeStation Variables of Boolean and String types are declared... versa Our simple Donchian Break Out is a pure stop and reverse system Click on MySignal-1 and click on the OK button Click the next button and a dialog box like the one in Figure 1.4 will open Figure 1.2 TradeStation 2000i—StrategyBuilder Building Winning Trading Systems with TradeStation TE AM FL Y 14 Figure 1.3 TradeStation StrategyBuilder—Add This dialog is informing us that there are two input variables... volume, and open interest is also available for each bar Since EasyLanguage works hand-in-hand with the charts that are created by TradeStation, there are many built-in reserved words to interface with the data These reserved words were derived from commonly used verbiage in the trading industry You can interface with the data by using the following reserved words (Note: Each word has an abbreviation... a stand-alone application; it is an independent program and can be run with or without TradeStation In the newer TradeStation 6.0, the PowerEditor is more of a component program; it runs within the confines of TradeStation TRADESTATION 2000i VERSUS TRADESTATION 6.0 As of the writing of this book, there are two versions of TradeStation currently being used: 2000i and 6.0 Based on input from users, we... was designed with the trader in mind Most of the trading techniques were designed and tested with indices, futures, and commodities (we focused on these markets due to their long histories with trading systems) Strictly equity traders will still get a good programming and good system design education Index (mini or full-size) and futures traders will be privy to five highly successful trading approaches... Insert Analysis Technique should open Click on the Strategy tab and select MyStrategy-1 from the list of available strategies and click on OK Another dialog box titled Format Strategy: MyStrategy-1 appears Click on the Inputs tab You will see the two inputs that we have coded in our 16 Building Winning Trading Systems with TradeStation Donchian Break Out signal By using the following line in our code, we... and logical expressions always result in true or false True is equivalent to 1, and False is equivalent to 0 String expressions deal with a string of characters You can assign string values to string variables and compare them 6 Building Winning Trading Systems with TradeStation myName1 myName2 cond1 = myName3 = "George Pruitt"; = "John Hill"; (myName1 myName2); = myName1 + " " + myName2; Concatenation... various other statistics Click on the Active Orders tab and you should see a LE (Long Entry) order to Buy 1 at a certain price stop and a SX (Short Exit) order 18 Building Winning Trading Systems with TradeStation Figure 1.6 Tracking Center TradeStation 2000i to Sell 1 at a certain price stop, if you are currently short If you are currently Long, you would see a SE (Short Entry) order to Sell 1 at a... familiarization on the use of the EasyLanguage built-in functions All users will benefit from the chapters that discuss proper trading system development We explore all areas of analysis techniques from Indicators to Paint Bars with a special emphasis on trading strategies Since a large portion of this book involves actual computer code, a companion CD-ROM, with all of the computer programs and data, is... two versions as 6.0 and 2000i TradeStation 6.0 is Omega Research’s all-inclusive trading tool Everything that you need to design, test, monitor, and execute an analysis technique is in one slick and complete package Omega Research is now a brokerage/software company and equities and futures trades can be executed through direct access with TradeStation Fundamentals 9 TradeStation 2000i PowerEditor . Cataloging-in-Publication Data: Pruitt, George, 1967– Building winning trading systems with TradeStation ™ / George Pruitt, John R. Hill. p. cm. — (the Wiley trading series) Includes index. ISBN 0-4 7 1-2 156 9-4 . Team-Fly ® Building Winning Trading Systems with TradeStation ™ Founded in 1807, John Wiley & Sons is the oldest independent publishing company in the United States. With offices. please contact our Customer Care Department within the United States at 80 0-7 6 2-2 974, outside the United States at 31 7-5 7 2-3 993 or fax 31 7-5 7 2-4 002. Wiley also publishes its books in a variety