TradeStation Made Easy!: Using EasyLanguage to Build Profits with the World's Most Popular Trading Software
By Bill Cruz and Sunny J. Harris
()
About this ebook
The majority of professional and individual traders use somekind of trading software on which to base their strategies. Withover 100,000 users, the most popular trading software today isTradeStation, published by TradeStation Technologies. While thissoftware is favored by many, TradeStation's computer language canbe confusing, especially for the novice.
TradeStation Made Easy! is the first and only book to explainexactly how to use the unique computer language behind thisbestselling software program. It is not meant as a replacement forthe TradeStation manuals, instead it will cover the essence ofprogramming in EasyLanguage and focus on a consistent set of dataand an elementary system throughout.
* An easily understood guide to TradeStation that also providestips for the user in designing a personalized trading system
* Endorsed by the software provider TradeStationTechnologies
* Written in a straightforward manner, that is accessible evenfor those with little computer experience
TradeStation Made Easy! fills a much-needed gap in thisarea and puts the basics of EasyLanguage in perspective. With it,you'll be able to write simple and intermediate programs that willaccurately express your theories and ideas about whatever marketinterests you.
Related to TradeStation Made Easy!
Titles in the series (100)
Full View Integrated Technical Analysis: A Systematic Approach to Active Stock Market Investing Rating: 0 out of 5 stars0 ratingsStrategies for Profiting with Japanese Candlestick Charts Rating: 2 out of 5 stars2/5Trading and Hedging with Agricultural Futures and Options Rating: 0 out of 5 stars0 ratingsThe Four Biggest Mistakes in Option Trading Rating: 4 out of 5 stars4/5Power Trading: Winning Guerrilla, Micro, and Core Tactics Rating: 3 out of 5 stars3/5Strategies for Profiting on Every Trade: Simple Lessons for Mastering the Market Rating: 4 out of 5 stars4/5Just a Trade a Day: Simple Ways to Profit from Predictable Market Moves Rating: 0 out of 5 stars0 ratingsThe Volatility Course Workbook: Step-by-Step Exercises to Help You Master The Volatility Course Rating: 0 out of 5 stars0 ratingsHarmonic Elliott Wave: The Case for Modification of R. N. Elliott's Impulsive Wave Structure Rating: 3 out of 5 stars3/5Hit and Run Trading: The Short-Term Stock Traders' Bible Rating: 0 out of 5 stars0 ratingsThe Universal Principles of Successful Trading: Essential Knowledge for All Traders in All Markets Rating: 3 out of 5 stars3/5Money-Making Candlestick Patterns: Backtested for Proven Results Rating: 0 out of 5 stars0 ratingsBreakthrough Strategies for Predicting Any Market: Charting Elliott Wave, Lucas, Fibonacci and Time for Profit Rating: 0 out of 5 stars0 ratingsBest Practices for Investment Committees Rating: 0 out of 5 stars0 ratingsIntra-Day Trading Tactics: Pristine.com's Stategies for Seizing Short-Term Opportunities Rating: 0 out of 5 stars0 ratingsIntra-Day Trading Strategies: Proven Steps to Trading Profits Rating: 0 out of 5 stars0 ratingsBig Money, Less Risk: Trade Options Rating: 0 out of 5 stars0 ratingsThe New Trader's Tax Solution: Money-Saving Strategies for the Serious Investor Rating: 3 out of 5 stars3/5Steidlmayer on Markets: Trading with Market Profile Rating: 3 out of 5 stars3/5Option Volatility Trading Strategies Rating: 3 out of 5 stars3/5Swing Trading Rating: 5 out of 5 stars5/5Stock Market Wizards: Interviews with America's Top Stock Traders Rating: 0 out of 5 stars0 ratingsEncyclopedia of Chart Patterns Rating: 5 out of 5 stars5/5Trading Pairs: Capturing Profits and Hedging Risk with Statistical Arbitrage Strategies Rating: 0 out of 5 stars0 ratingsHow I Trade Options Rating: 3 out of 5 stars3/5Sector Trading Strategies Rating: 5 out of 5 stars5/5The Options Course: High Profit and Low Stress Trading Methods Rating: 0 out of 5 stars0 ratingsCybernetic Analysis for Stocks and Futures: Cutting-Edge DSP Technology to Improve Your Trading Rating: 5 out of 5 stars5/5Intermarket Analysis: Profiting from Global Market Relationships Rating: 4 out of 5 stars4/5
Related ebooks
Trading Options: Using Technical Analysis to Design Winning Trades Rating: 0 out of 5 stars0 ratingsPoint and Figure Charting: The Essential Application for Forecasting and Tracking Market Prices Rating: 5 out of 5 stars5/5Cycle Analytics for Traders: Advanced Technical Trading Concepts Rating: 0 out of 5 stars0 ratingsCandlestick and Pivot Point Trading Triggers: Setups for Stock, Forex, and Futures Markets Rating: 0 out of 5 stars0 ratingsA Guide to Creating A Successful Algorithmic Trading Strategy Rating: 4 out of 5 stars4/5Alpha Trading: Profitable Strategies That Remove Directional Risk Rating: 2 out of 5 stars2/5All About Market Indicators Rating: 5 out of 5 stars5/5Trading Triads: Unlocking the Secrets of Market Structure and Trading in Any Market Rating: 0 out of 5 stars0 ratingsHigh Probability Trading Strategies: Entry to Exit Tactics for the Forex, Futures, and Stock Markets Rating: 4 out of 5 stars4/5Cybernetic Analysis for Stocks and Futures: Cutting-Edge DSP Technology to Improve Your Trading Rating: 5 out of 5 stars5/5Trading the Measured Move: A Path to Trading Success in a World of Algos and High Frequency Trading Rating: 0 out of 5 stars0 ratingsAn Introduction to Algorithmic Trading: Basic to Advanced Strategies Rating: 5 out of 5 stars5/5Master Traders: Strategies for Superior Returns from Today's Top Traders Rating: 0 out of 5 stars0 ratingsAll About Day Trading Rating: 5 out of 5 stars5/5Trend Qualification and Trading: Techniques To Identify the Best Trends to Trade Rating: 2 out of 5 stars2/5How to Price and Trade Options: Identify, Analyze, and Execute the Best Trade Probabilities, + Website Rating: 0 out of 5 stars0 ratingsTrend Trading Set-Ups: Entering and Exiting Trends for Maximum Profit Rating: 2 out of 5 stars2/5Simple Profits from Swing Trading: The UndergroundTrader Swing Trading System Explained Rating: 0 out of 5 stars0 ratingsTrend Trading for a Living: Learn the Skills and Gain the Confidence to Trade for a Living Rating: 5 out of 5 stars5/5Option Volatility & Pricing: Advanced Trading Strategies and Techniques Rating: 0 out of 5 stars0 ratingsAlgorithmic Trading: Winning Strategies and Their Rationale Rating: 3 out of 5 stars3/5Adaptive Analysis for Stocks Rating: 4 out of 5 stars4/5The Art and Science of Technical Analysis: Market Structure, Price Action, and Trading Strategies Rating: 4 out of 5 stars4/5Study Guide for The New Trading for a Living Rating: 5 out of 5 stars5/5Basic Option Volatility Strategies: Understanding Popular Pricing Models Rating: 0 out of 5 stars0 ratings
Investments & Securities For You
How to Invest: Masters on the Craft Rating: 4 out of 5 stars4/5Don't Start a Side Hustle!: Work Less, Earn More, and Live Free Rating: 5 out of 5 stars5/5The Little Book of Common Sense Investing: The Only Way to Guarantee Your Fair Share of Stock Market Returns Rating: 4 out of 5 stars4/5Stock Investing For Dummies Rating: 5 out of 5 stars5/5Principles: Life and Work Rating: 4 out of 5 stars4/5The Intelligent Investor, Rev. Ed: The Definitive Book on Value Investing Rating: 4 out of 5 stars4/5Buy, Rehab, Rent, Refinance, Repeat: The BRRRR Rental Property Investment Strategy Made Simple Rating: 5 out of 5 stars5/5How to Make Money in Stocks: A Winning System in Good Times and Bad, Fourth Edition Rating: 5 out of 5 stars5/5Girls That Invest: Your Guide to Financial Independence through Shares and Stocks Rating: 5 out of 5 stars5/5Options Trading Crash Course: The #1 Beginner's Guide to Make Money with Trading Options in 7 Days or Less! Rating: 5 out of 5 stars5/5The Only Investment Guide You'll Ever Need Rating: 5 out of 5 stars5/5Buy Then Build: How Acquisition Entrepreneurs Outsmart the Startup Game Rating: 4 out of 5 stars4/5Long-Distance Real Estate Investing: How to Buy, Rehab, and Manage Out-of-State Rental Properties Rating: 5 out of 5 stars5/5Options Trading For Dummies Rating: 0 out of 5 stars0 ratingsHow to Invest in Real Estate: The Ultimate Beginner's Guide to Getting Started Rating: 5 out of 5 stars5/5Real Estate by the Numbers: A Complete Reference Guide to Deal Analysis Rating: 0 out of 5 stars0 ratingsStock Market Investing for Beginners & Dummies Rating: 5 out of 5 stars5/5All About Asset Allocation, Second Edition Rating: 4 out of 5 stars4/5SIE Exam Practice Question Workbook: Seven Full-Length Practice Exams (2024 Edition) Rating: 5 out of 5 stars5/5Best Loser Wins: Why Normal Thinking Never Wins the Trading Game – written by a high-stake day trader Rating: 5 out of 5 stars5/5
Reviews for TradeStation Made Easy!
0 ratings0 reviews
Book preview
TradeStation Made Easy! - Bill Cruz
Contents
Cover
Series
Title Page
Copyright
Dedication
Epigraph
Foreword
Preface
Acknowledgments
Author’s Note
Chapter 1: Introduction to EasyLanguage
INTRODUCTION
WHAT THIS BOOK IS NOT
WHAT THIS BOOK IS
A CHART IS A CHART IS A CHART
FONTS, SYMBOLS, AND CONVENTIONS
Chapter 2: Quick Start
INTRODUCTION
PSEUDO-STEPS
DETAILED STEPS
CONCLUSION
Chapter 3: Understanding the Process
REVIEW
STEP 1: OBSERVATION
STEP 3: PROGRAMMING AND QUALITY ASSURANCE
STEP 4: MARKETING AND SALES
SUMMARY
Chapter 4: Basic Use of TradeStation
INTRODUCTION
BASIC ELEMENTS OF TRADESTATION
OLDER VERSIONS OF TRADESTATION: READ THIS SECTION
ALL VERSIONS COME HERE
QUICK START TO TAILORING YOUR CHART AND STRATEGY
Chapter 5: Basic Math
INTRODUCTION
ADDING AND SUBTRACTING
MULTIPLYING AND DIVIDING
DECIMALS AND FRACTIONS
ABSOLUTE VALUE
PERCENTAGES
RATIOS AND PROPORTIONS
EXPONENTIATION (POWERS) AND LOGARITHMS
LINEAR AND SEMI-LOG SCALING
RELATIONAL OPERATORS
AVERAGES
ANSWERS
Chapter 6: Basic EasyLanguage
INTRODUCTION
SKELETONS (TEMPLATES)
WRITING YOUR OWN
CHARTING YOUR INDICATOR
SUMMARY
Chapter 7: Programming Conventions
INTRODUCTION
ORDER DEPENDENCIES AND THE LIBERAL USE OF PARENTHESES
TAKE IT SLOWLY—ONE STEP AT A TIME
PUNCTUATION
SKIP WORDS
ALL ABOUT BARS
CURRENTBAR
MAXBARSBACK
INPUTS AND VARIABLES
VARIABLES
STATEMENTS
COMMAND STRUCTURE
PROGRAM STRUCTURE
FLOW
COMMENTS
VERIFYING YOUR CODE
ERROR HANDLING
DEBUGGING TRICKS
BREAKPOINT
Chapter 8: Statements
INTRODUCTION
DECLARATION STATEMENTS
VARIABLES
INPUTS
ASSIGNMENT STATEMENTS
DATA MANIPULATION
PRINT STATEMENTS
FORMATTING IN THE PRINT STATEMENT
DECIMAL PLACES
LABELS FOR READABILITY
IF…THEN STATEMENTS
PLOT STATEMENTS
Chapter 9: Ifs, Ands, and Buts
INTRODUCTION
SYMBOLIC LOGIC
TRUTH TABLES
DECISIONS (CONDITIONS)
REAL-LIFE EXAMPLE
MORE ABOUT IF AND IF … THEN … ELSE
Chapter 10: Begin and End (Block Statements)
INTRODUCTION
BLOCK STATEMENTS
NESTED BLOCK STATEMENTS
WORKING ON OUR STRATEGY
Chapter 11: Loops
INTRODUCTION
FOR
WHILE
Chapter 12: Analysis Techniques
INTRODUCTION
USING STRATEGIES
WRITING YOUR OWN SYSTEMS, STRATEGIES, AND SIGNALS
ALTERING TRADESTATION’S STRATEGIES
EVALUATING STRATEGIES
BUILT-IN INDICATORS
WRITING INDICATORS
SHOWME
PAINTBARS
FUNCTIONS
Chapter 13: Buying and Selling
INTRODUCTION
ENTRIES
ORDER NAMES
EXITS
Chapter 14: Functions
WHAT IS A FUNCTION?
STRUCTURE OF A FUNCTION
TEMPLATE FOR A FUNCTION
EXAMPLES OF FUNCTIONS
Chapter 15: Tricky Math
INTRODUCTION
SIGN OF A NUMBER
ROUNDING, TRUNCATING, AND INTEGER ARITHMETIC
MINIMA AND MAXIMA
Chapter 16: TradeStation Tricks
INTRODUCTION
TRICKS WITHIN TRADESTATION
TIPS AND TRICKS FROM BILL BROWER
EIGHT BALL FROM THE TRADESTATION USERS’ FORUM
TIPS AND TRICKS FROM LARRY WILLIAMS
TIPS AND TRICKS FROM TRADESTATION STAD
TIPS AND TRICKS FROM SAMUEL K. TENNIS
TIPS AND TRICKS FROM EASYLANGUAGE HOME STUDY COURSE
TIPS AND TRICKS FROM GLEN LARSON (OF GENESIS FINANCIAL TECHNOLOGIES)
TIPS AND TRICKS FROM ARTHUR G. PUTT
TIPS AND TRICKS FROM THE TRADESTATION NEWSLETTER
FILEAPPEND
SUMMARY
Chapter 17: Optimization
INTRODUCTION
WHAT IS OPTIMIZATION?
HOW MUCH IS ENOUGH?
WHEN TO OPTIMIZE
RUN THE OPTIMIZATION
CHANGING THE OPTIMIZATION CRITERIA
WORKING WITH THE OPTIMIZATION REPORT
CURIOUSER AND CURIOUSER
CONCLUSION
Chapter 18: System Performance
INTRODUCTION
PERFORMANCE SUMMARY
TRADE-BY-TRADE REPORTS
SUNNY’S IMPORTANT NUMBERS
SHARPE RATIO
Chapter 19: Conclusion
SUMMARY: PUTTING IT ALL TOGETHER
LAST WORDS
Appendix A: Styles
LINE STYLE
COLORS
Appendix B: Reserved Words
RESERVED WORD AND MEANING
A
B
C
D
E
F
G
H
I
J
L
M
N
O
P
Q
R
S
T
U
V
W
Y
Appendix C: Formulas
ASYMMETRICAL LEVERAGE
CPC™ (CARDINAL PROFITABILITY CONSTRUCTS)
EXPONENTIAL MOVING AVERAGE
HERICKPAYOFF INDEX
MARKET FACILITATION INDEX
MATHEMATICAL EXPECTATION (ME)
MOVING AVERAGE (MAV)
MARKET FACILITATION INDEX
OPTIMAL-F
PERCENT PROFITABILITY
PESSIMISTIC RETURN RATIO (PRR)
PHW™ (POTENTIAL HOURLY WAGE)
PROFIT FACTOR
RATIO OF THE AVERAGE PROFITABLE TRADE TO THE AVERAGE LOSING TRADE (P/L RATIO)
WILDER’S RSI
RUNS
STOCHASTICS
Appendix D: Full Code for the Systems and Studies in This Book
SIGNAL TO CLOSE THE OPEN TRADE
INDICATOR FOR 200-DAY MOVING AVERAGE
PAINTBAR FOR 200-DAY MOVING AVERAGE
SHOWME FOR 200-DAY MOVING AVERAGE
FILTER FOR 200-DAY MOVING AVERAGE
OUR STRATEGY
Appendix E: Baskets
Appendix F: Where’s the Command?
Appendix G.1: Built-in Functions and Indicators (Alphabetical Listing)
Appendix G.2: Built-in Functions and Indicators (Functional Listing)
FUNCTIONS AND INDICATORS
Appendix H: TradeStation Add-on Products and Services
TRADER’S CATALOG & RESOURCE GUIDE™: THE FINANCIAL YELLOW PAGES
Appendix I: TradeStation User Groups
Appendix J: Error Messages
Appendix K: What’s Wrong with This Code?
Bibliography
Index
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 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, visit our Web site at www.WileyFinance.com.
Title PageCopyright © 2011 by Sunny J. Harris. 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.
TradeStation, OptionStation and SuperCharts are registered trademarks of TradeStation, Inc. TradeStation ProSuite, ActivityBars, EasyLanguage, GlobalServer, HISTORYBANK Financial Database, PaintBar, Portfolio Maximizer, PowerEditor, ProbabilityMaps, RadarScreen, ShowMe, SmartAsk, SmartBid, SmartStyling and SystemBuilder are trademarks of TradeStation, Inc. HISTORYBANK.COM and OmegaWorld are service marks of TradeStation, Inc. Other names and marks referred to are the property of their respective owners.
In recognition of TradeStation’s trademarks and copyrights, uses in the book of TradeStation, EasyLanguage, OptionStation, Historybank.com, GlobalServer or Super Charts imply TradeStation TradeStation, TradeStation EasyLanguage, TradeStation OptionStation, TradeStation Historybank.com, TradeStation Super Charts and TradeStation GlobalServer respectively.
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 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.
ISBN 978-0-471-35353-9; ISBN 978-1-118-06315-6 (ebk);
ISBN 978-1-118-06316-3 (ebk); ISBN 978-1-118-06317-0 (ebk)
I’ve been working on this book since 1996; that’s 12 years now. Wow! When I first began, my daughter was pregnant with my second grandson, whose name is Sterling Kodiak Yates, now 10. This book is dedicated to Sterling and to my back-ordered grandchildren (hopefully from my son’s new wife, Laurel).
The human mind, once stretched to include a single new idea, does not shrink back to its original proportions.
–Oliver Wendell Holmes
Until one is committed, there is hesitancy.
–W. H. Murray
We must never assume that which is incapable of proof.
–G. H. Lewes
Be sure of it; give me the ocular proof.
–Shakespeare
Foreword
One of the early users of TradeStation software, Sunny Harris has been studying and programming trading strategies for more than 30 years.
I have watched her progress as a researcher and trader over the years, from the time we were still offering the DOS version of SystemWriter and TradeStation was a fledgling company.
Sunny is one of the most studious and diligent people I know and gives generously in teaching others what she has learned through the school of hard knocks. Having a software background herself, and writing books that focus on helping beginners (Trading 101—How to Trade Like a Pro, Trading 102—Getting Down to Business, Electronic Day Trading 101, and Getting Started in Trading) have inevitably led to the writing of this book.
Successful traders have one thing in common: they approach trading by developing an objective strategy and then use it consistently.
TradeStation allows traders to design their own trading strategies, back-test them on years of historical data, and then computer-automate them. The power of EasyLanguage is what makes all of this possible. Therefore, by mastering EasyLanguage, you have the power to test any idea you can imagine.
Through the many examples, Sunny Harris walks you through in this book, you’ll have a much better understanding of how to use EasyLanguage to create your own strategies. This book also provides you with an invaluable guide for trading strategy development that will contribute greatly to the understanding and improvement of your EasyLanguage skills.
Sunny’s unique ability to blend her highly theoretical math degrees with her artistic and graphics talents makes her understanding of markets both logical and intuitive. She has been a friend of TradeStation for many years, always lending insight and advice, and as one of our beta testers she has helped create the best possible market analysis software there is today: TradeStation.
Analyzing the markets can be daunting—a task taken on by many but mastered by few. As an aid to all analysts, our software has to be ready manage incredibly difficult tasks and the most pedantic at the same time. Sunny’s 20-plus years of self-taught market analysis combined with her 10 years of experience teaching others to trade has led her to write the most readable and invaluable of books about EasyLanguage.
Through the many examples in this book, you’ll have a much better understanding of how to use EasyLanguage to create your own strategies. This book also provides you with an invaluable guide for trading strategy development that will contribute greatly to the understanding and improvement of your EasyLanguage skills.
The time you invest in mastering EasyLanguage will be the best investment of your trading life.
If you are a TradeStation or ProSuite user, this book is a must. If you are serious about learning to trade, read Sunny’s books—the truth lies within.
I wish you a very successful trading career.
Bill Cruz
Founder and former CEO of TradeStation
Preface
This book is one of a kind. It is perhaps the only book written by a self-taught Easy-Language speaker (programmer) who learned and helped improve EasyLanguage before there was even a TradeStation, and who is an actual trader.
I was trading beginning in 1981, when just about the only good graphics analysis package was called MasterChartist, by Roberts-Slade. The problem was, there was no testing language with which to evaluate and back-test your trading ideas. Back then we were running DOS only; or, there was no Windows yet. Testing your strategies amounted to using a rudimentary version of Excel and pencil and paper. It was tedious at best.
Along came a program by Omega Research, called SystemWriter Plus. It was a god send! At last I could rough out my ideas and test them against mounds of historical data. However, as with everything, there was a serious drawback. It only worked on daily data, not on intraday data. I was able to receive intraday data on MasterChartist but not to test it. I could draw (with a pencil) on the charts but not strategize buy and sell opportunities. With SystemWriter Plus I could print out mounds of data analysis, but the charts were rudimentary, coming out of a dot matrix printer, and only on daily data. What to do?
As necessity is the mother of invention, I decided to divide my real-time data from MasterChartist into 15-minute increments and treat it as if it were daily data over a very long period of time. I imported the fake daily data into SystemWriter. It took me 18 months to massage the data and convert it into years and years worth of 15-minute increments. (There was no CompuTrac yet either.) In order to make sense of a chart, it is necessary to demarcate dates and times along the x-axis. This took some ingenuity, and some gerfingerpointing.
I created a ruler with tiny marks along each day to designate 15-minute increments and ignored the Monday, Tuesday, Wednesday markings on the chart itself. To find a time during any particular day, I had to measure and mark divisions with my specially marked ruler.
It worked. I was able to test intraday trading concepts and determine success or failure statistically, even without software that operated on an intraday basis. Finally, Microsoft invented Windows, and the software vendors followed suit with more and more sophisticated programs, soon allowing not only 15-minute increment data but any minute divisions and even tick-by-tick charts.
The most important component of this new and powerful tool was in running walk-back and walk-forward tests. Did my theory of making profits hold up last week, last month, and last year? It quickly became obvious that I could spot a theory that would work for the past three Fridays; but when I tried it in real time, I lost money for the next three Fridays. Why did that happen?
For several years I plugged away with spreadsheet, pencil, and lots of erasers at hand, keeping copious notes of the ideas that I tried against market data to see if there was any hope of creating a mechanical system that worked.
What did worked
mean? That in itself is a whole ’nother problem. I realized I had two large problems: finding a system that worked and finding a set of statistics that measured success. It took me the better part of three years devoting 18 hours a day to the task to come up with a meaningful system and statistics that measured its success.
In this book I share with the reader not only what I learned through three solid and dedicated years of 18-hour research days, but what I have learned subsequently through real-time trading. I wish you the best in your efforts. But I would admonish you to read this book over and again and to spend the time doing your own research following the pattern set out herein.
And now it’s 2010---and according to author Thomas Friedman, the world is flat. We are living in a flat world devoid of boundaries of language, communications, or even time constraints. We can talk with anyone, anytime, anywhere with the help of email, Skype, GoogleTalk, and tiny onboard cameras. Our computers and software are purchased over the Internet, constructed of tiny parts made in China and Taiwan, and our customer support folks are in India. When the market crashed in September 2008, it was China that bought 49% of our debt from many of our banks. No more walls. Even our cell phones are now computers that link us with the whole world: I can take your picture and send it with text to anyone, anywhere. I can make a PowerPoint presentation, put it in pdf format, and make my product demonstration to you from my cell phone or my PDA. It’s endless and magnificent.
Without EasyLanguage, where would we all be? Someone had to do it. And, as luck, good fortune, and the wisdom to see and act on the opportunity would have it, the Cruz brothers and their sister (Ralph, Bill and Michelle) were the team to pick up the gauntlet and run with it. And now we trade 24-hour markets, all over the world, in a flash, with the push of a button on a TradeStation screen. The data is next to free, the software is included in the price of your having an account at TradeStation Securities, and the commissions are ridiculously low.
It’s a M-U-R-I-C-A-L. (Miracle.)
TradeStation almost doesn’t need a manual. It is so easy to use and so intuitive that it almost seems silly to write this book. But there is more to it than just a users’ manual. Besides getting the software up and running on your computer, you need the benefit of my years and years of experience making every mistake in the book.
There is no need for you to repeat my errors, nor for you to hunt and peck your way to success. In this book I hope to lead you through the process of installing the program, using it for the first time or two, and writing your first several indicators and strategies. If you tried it on your own, from the TradeStation Users’ Manual, you would probably give up before you even got to the point of trading. By design, all users’ manuals are full of technical descriptions of all the program’s bells and whistles from A to Z. In that order. There’s no rhyme or reason to what the user needs to do first, second, and third: it’s just an alphabetical reference to everything in the program.
Instead of a reference manual, however, with this tome I am writing a cookbook. Step 1, do this; step 2, do that. It is a simplistic approach, but one that will get you on the road to doing it yourself much quicker and with much more confidence. Then you can go back to the reference materials with some understanding of what to look for.
One more thing before I get on with it. I have been using TradeStation since before it was called TradeStation. I have seen the versions go from 1, to 2, all the way to 8.8 and now 9.0, which is the version I am currently using. In many ways all the versions are alike, and in many ways they differ vastly. When I first started writing this book, I thought I would give instructions for the most recent three versions of TS and compare and contrast the differences. As the years went on and the book progressed, the versions kept coming and coming and coming---faster than I could write. And that is still true. As I am putting the finishing touches on the manuscript, yet another version of TS has been released, which differs in many respects from the prior version. Never fear! This book applies to them all.
One of the biggest differences between TradeStation 2000i and TradeStation 4.0 is in the way they engage systems. TradeStation 2000i made enhancements for testing a variety of entries and exits without getting back into EasyLanguage and modifying your code. This can be a great advantage, unless you are entrenched in the methods of 4.0 and are reluctant to change. On first inspection, it would seem that TradeStation has added two steps to every attempt to employ a system, and initially that is irritating. But once you realize the tremendous advantages to mixing and matching entry and exit signals, you’ll get used to it and be thankful.
After version 2000i, the company again integrated EasyLanguage with the main program. With versions 8.8 and 9.0 it has once again separated the EasyLanguage Editor from the main program and made it stand-alone. In spite of all these changes, this book will apply universally to all versions before and hereafter. Don’t worry if you are reading this book years after it was first released. The concepts are applicable to whatever version of TradeStation you are using.
With version 9.0 TradeStation’s EasyLanguage is a complete programming language, much like VB or C++. It has tremendous strides in extensibility for programmers. We are not going to address any of that in this easy book. that will be left for the advanced book.
Acknowledgments
Thanks to Pamela van Giessen for originally telling me I could write, and encouraging me to write my first book, Trading 101—How to Trade Like a Pro. I really thought that I had nothing to say.
And thanks to Bill Cruz, co-founder of TradeStation, who helped me along the way with learning EasyLanguage.
Because of all he has contributed to this industry, and to my personal learning, a great big thanks goes out to Larry Williams, who really trades for a living.
My 88-year-old, nearly blind, mother proofread this manuscript with her magnifying glass, all 733 pages of it. I’m eternally grateful for her help and her inspiration. My children and grandchildren have been patient and understanding as I sat behind my laptop while they watched TV and movies, played games, and built Lego monuments. I’ve been halfway participating for years during the growth of this tome. I thank them for their creativity and their love.
And most of all, I thank my partner of 21 years for her continued support and understanding and encouragement during thick and thin. She’s an exceptional partner and a magnificent physician.
To those who are reading this book, I thank you also. You will grow by immeasurable bounds as you read and learn. Keep up the good work. And tell your friends.
Author’s Note
Please understand that this book is intended to be educational in nature. I am not recommending that you trade, nor am I giving trading advice. Further, I am not suggesting that any of the methods presented in this book will generate a profit or will not generate losses.
Sunny J. Harris, Sunny Harris & Associates, Inc. and Sunny Harris Enterprises, Inc. accept no liability whatsoever for any loss arising from any use of this information.
This information is in no way a representation to buy or sell securities, bonds, options, or futures. Always check with your licensed financial planner or broker before buying or selling on any advice whether contained herein or elsewhere.
It should not be assumed that the methods, techniques, or indicators presented in this book will be profitable or that they will not result in losses. Past results are not necessarily indicative of future results. Examples in this book are for educational purposes only. This is not a solicitation of any offer to buy or sell.
Trading and investing are speculative and include risk of loss. Past performance is no indication of future results.
Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades may not have been executed, the results may have under- or overcompensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown.
Any statements of facts herein contained are derived from sources believed to be reliable but are not guaranteed as to accuracy, nor do they purport to be complete. No responsibility is assumed with respect to any such statement, nor with respect to any expression of opinion herein contained. All trade recommendations should be discussed with your broker and made at your own risk.
Chapter 1
Introduction to EasyLanguage
INTRODUCTION
EasyLanguage is TradeStation’s proprietary command language that lets you specify your trading ideas in plain English and test them before you trade. EasyLanguage allows you to write your own trading systems for TradeStation, OptionStation, and ProSuite without having to know complicated computer programming languages.
EasyLanguage is one of the most powerful and useful features of TradeStation and with some practice, you can become an expert, even if your background in computers is limited.
That said (it’s from the splash screen introduction to TradeStation software), all software comes with stumbling blocks. I have yet to open a software box and install and use the product with no problems along the way. Furthermore, TradeStation’s EasyLanguage is more than just software; it’s a programming language. And with the advent of the new Object-Oriented EasyLanguage with TradeStation version 9.0, it is more like C++ than any easy language. Albeit the easiest to use of the complex trading tools, it is still so full of features that it can’t help but be difficult in spots. As I work with EasyLanguage I hum the old song by The Essex from 1963: ``Easier Said Than Done.’’
The working title for the ideas presented in this book was EasyLanguage Ain’t.
Neither Bill Cruz, prior co-CEO of TradeStation, nor my editor, Pamela van Giessen, liked that title. Nevertheless, the viewing public seemed to appreciate the reality of the working title. Each time I mentioned the project in a lecture I got nods of recognition from non-programming TradeStation, SuperCharts, and OptionStation users.
EasyLanguage Ain’t
was never meant to be disparaging to TradeStation, but rather a reflection of the simple truth that programming a computer, no matter how friendly the programming language, is never easy. Becoming a good coder takes study, sometimes years of study. It is the intent of this book to walk the reader through that learning process in small and simple steps that will make the process comfortable. I have recently noticed the tendency of some of my competitors to use the paraphrase EasyLanguage Isn’t,
and I herewith forgive them their lack of imagination.
Computer manuals aren’t meant to be read cover to cover. The TradeStation Users’ Manual is no exception. TradeStation Made Easy! however, is intended to be read from cover to cover, with pauses along the way to try the examples. Hopefully it will be an informative and enjoyable experience for you. After reading this book, you will be more prepared to go back and use the TradeStation manuals with ease and as reference.
In Trading 101—How to Trade Like a Pro, I wanted to introduce the basic concepts of trading to the general public. In Trading 102—Getting Down to Business my hope was to introduce the concepts of system design and testing. TradeStation Made Easy! is intended as a procedural guide to getting comfortable with programming Trade-Station’s EasyLanguage.
At the same time I am writing this book I am also researching one more: Grading the Gurus. You will probably be interested in Gurus as well, since it is all about using TradeStation (and other popular software) to test the theories, strategies and technical analysis of some of the famous systems designers. The intent of the Gurus book is to discover both the advantages and downfalls of following other people’s systems. After that I want to write a book exploring all the commonly available systems and strategies from nongurus, strategies you find published in books, their benefits and pitfalls, and maybe call it Breaking the Rules.
We, the trading public, owe a debt of gratitude to Bill and Ralph Cruz and their crew, whose dedication to an initially narrow market has expanded that market and created tools we can all use to profitable ends. Thanks, guys; you have a great product.
During late January of 1999 I took a little trip to the Bahamas and then to Miami, where I had the pleasure of spending several days with TradeStation personnel. The purpose of my visit was to get an advance look at the impending, latest release of TradeStation, called 2000i, as part of the research for this book. For their generosity, hospitality, and help I would like to thank Loren Costantino, Gaston Sanchez, Kevin Feuerlicht, Amy Solt, Janette Perez, Bill and Ralph Cruz and the rest of the TradeStation staff. You’re the greatest!
WHAT THIS BOOK IS NOT
TradeStation Made Easy is not meant as a replacement for the TradeStation manuals. This programming guide is not meant to help you learn the mechanics of setting up Trade-Station or your computer, or to help you with the trials and tribulations of getting data into your computer.
This book is also not meant to teach you systems, or to give you systems that are necessarily profitable, though we may discover some along the way. We will cover the essence of programming in EasyLanguage and stick with a consistent set of data and a consistent elementary system throughout. We will not fill the book with a variety of working systems with which you can experiment; there are other books for that.
In particular, if you are looking for fancy EasyLanguage programming ideas I would suggest these sources:
Cynthia Kase
Kase and Company, Inc.
PO Box 226 Cheyenne, WY 82003
(505) 237-1600
www.kaseco.com
Joe Krutsinger
PO Box 4223
Kansas City, KS 66104
(800) 927-1035
www.joekrut.com
Using Easy Languageby Arthur G. Putt
available from Ruggiero Press
Murray Ruggiero
Ruggiero Press
18 Oregon Ave., East Haven, CT 06512
1-203-564-1956
TS Expressby Bill Brower
Inside Edge Systems, Inc.
10 Fresenius Rd., Westport, CT 06880
1-203-454-2754
Ask Mr. EasyLanguageby Sam Tennis
129 Staff Drive, NE
Fort Walton Beach, FL 32548
1-850-243-5105
http://www.vista-research.com
WHAT THIS BOOK IS
This book is a guide to understanding the basics and beginning to use EasyLanguage. I offer this service because it fills a gap—no one else has dedicated their writings to the beginners. The more advanced tasks to becoming a TradeStation expert are between you and TradeStation, and perhaps a consultant to help you along the way. Bill Brower is an excellent resource for advanced techniques, but his efforts at teaching beginners are still too advanced for most novices.
By the end of this book you will be able to write simple and intermediate programs using EasyLanguage. Hopefully your programs will accurately reflect the theories you have, discover, or read about the markets.
By the end of this book you will have the confidence to open TradeStation’s PowerEditor to a blank page and begin writing.
As I began this book, I put in examples for all the existing versions of TradeStation at that time. Now, many years later, I’m pruning it all down to the current version only. All references to ProSuite, 2000i, and earlier versions of TradeStation are being removed. If you need help with a previous version of TradeStation, give me a call and we’ll talk about it.
A CHART IS A CHART IS A CHART
This book is not about learning to trade; it is about learning to program.
Nevertheless, throughout the book we will be reviewing and using trading concepts as examples while learning to program. In learning programming concepts, it really does not matter what our underlying data is. What we will cover in this book is how to express your theories and ideas about whatever market interests you, independent of any particular market.
A chart, is a chart, is a chart. They all go up, or down, or sideways, or all three. If you were not told what instrument (stock, bond, mutual fund, commodity) was used to produce the chart in Figure 1.1, you would not be able to guess it. No, it is not the Dow. I have not given you a reference axis for time frame (X-axis), nor is there a reference axis for price (Y-axis). In spite of that absence of information, you could tell me some things about the chart. You could tell me that the second half of the chart is less volatile than the first half. You could tell me that in the beginning, price moves downward. You could tell me that after the beginning downward move, there is a period of nearly upward movement followed by downward movement. You could not tell me that in general the bias is to the upside. You could also tell me there is a mild correction (downward movement) in the last third of the chart.
(In fact, I will give a crisp new $20 bill to the first person who calls me and correctly identifies the chart in Figure 1.1.)
FIGURE 1.1 An Anonymous Chart
ch01fig002.epsThis sort of analysis is what I call What is?
or What is true?
I begin every investigation by repeatedly asking myself ``What is true of the chart at which I am looking?’’ It’s the what is
that leads to rich brainstorming sessions and possibilities for analysis.
What you could not tell me is whether this is a chart of a commodity, stock, or mutual fund. You could not tell me if it is a chart of 1-minute, 5-minute, 60-minute, or daily data. And you could not tell me whether this price action happened in 1927, 1987, or 2010.
In fact, this is an example of what they mean when they say the markets are fractal. Each subset, or smaller time frame, looks like any other time frame. They all go up, they all go down, and they all go sideways. It’s just another way of saying a chart is a chart is a chart.
For the purpose of this book, the particulars of the chart do not matter; what matters is that the chart has movement and that we can describe it in programming language.
The best way I know to make this book easy to use and comprehend is to build on a simple concept from beginning to end. To this end, I will introduce a single set of data that we will use throughout. That data is available for you on my Web site: www.moneymentor.com/TSME.html. If you’d like to receive a CD of the data, just contact my office in California at 1-760-444-4174 Skype or my cell at 1-760-908-3070. I ask only that you observe Pacific Standard Time.
We will use the same chart and the same data throughout this book. We will take different perspectives, sometimes viewing daily data, sometimes weekly, sometimes intraday, but it will all be of the same vehicle. I have always wondered why authors choose a different chart to illustrate every new concept. I’ve wondered whether the concepts are only applicable to certain subsets of charts. As I tackle this book, I guess I am about to find out.
I will also start early in this book with a simple program to analyze the data and build on that program as we progress. That way you will be learning about the structure of EasyLanguage, not struggling with a new program every few pages. You will become intimately familiar with one set of data and one small program. We will analyze this single set of data at increasing depth, and will alter and enhance our initial program until it becomes sophisticated.
After you finish this book you can easily branch off and apply your new language to very complex concepts. You will be able to understand many of the sophisticated techniques presented in Omega magazine, TradeStation’s manuals, Technical Analysis of Stocks & Commodities magazine, Futures magazine, Traders’ Catalog & Resource Guide, and the various other sources and books mentioned herein.
FONTS, SYMBOLS, AND CONVENTIONS
I’ve used a few symbols in the book and some typefaces to separate code from text. All programming code herein is designated by using the typeface OCRA. All computer commands are shown in the typeface Helvetica. An arrow (→) means to pull down the menu and choose the next command. A mouse symbol ( eps ) means to use the mouse to pull down or click to the command. Everything else is pretty much self-explanatory.
Chapter 2
Quick Start
In This Chapter
Introduction
Pseudo-Steps
Detailed Steps
Conclusion
INTRODUCTION
You just spent a small fortune on trading software, data, and computers and you can’t even use it. Or you opened a hefty trading account with TradeStation just so you could use the software. You probably thought that getting TradeStation was the solution to all your trading problems, not the beginning of them. You just want to trade, not to become a programmer. Right? And now, with the new version, 9, it has been extended into a full-fledged programming language.
The first step I like to take with students is to show them how easy TradeStation really is to use. Because of the vast capabilities of the software, it can appear that the learning curve is insurmountably steep. Broken down into the elementary steps, however, you will find that using TradeStation is actually quite simple and straightforward. TradeStation really is the toolbox that lets you solve all your trading problems.
Just to show you how easy it can be, this Quick Start chapter will guide you through the steps of writing your first system, the associated indicator, and checking your profit or loss. I will not offer detailed explanation of the steps in this chapter. I just want you to have a template for success. Later, throughout the book, we will go over the details.
It’s easy to get a computer to do something. It is not always easy to get it to do what you want it to. Computers will do exactly what you tell them, no more, no less. The challenge is always in putting your thoughts into clear, logical steps that mean the same thing to the computer that they mean to you.
PSEUDO-STEPS
I like to use pseudo-code
to sketch a map for myself. Writing the pseudo-code is essentially defining your goal and making an outline. Whenever I begin a new project, no matter how large or how small, I like to have a goal and an outline of how to get there. (This especially goes for driving, since I can get lost going home from work. In fact, I have GPS and printed driving instructions from MapQuest.com when I’m going somewhere, just in case.) Without a clearly defined goal and milestones, you won’t get there!
The pseudo-code for the process covered in this book might look something like:
1. Open TradeStation.
2. Open chart with data.
3. Open EasyLanguage PowerEditor.
4. Write indicator.
5. Put indicator on chart.
6. Write system.
7. Apply system to chart.
8. View system results.
9. If system results exceed CPC™ Index, then prepare to trade, else loop back to step 6 and continue homework.
We will go through those steps now, one at a time.
DETAILED STEPS
Step 1: Open TradeStation
Opening TradeStation is as easy as 1, 2, 3, 4, 5.
1. First, double-click the TradeStation icon eps on your PC’s desktop (assuming you have already installed TradeStation from CD or download). This icon will vary slightly depending on the version you are using.
2. Then fill in your name and password in the pop-up box shown in Figure 2.1.
FIGURE 2.1 Login Screen
ch02fig013.eps3. Now click the Logon button, or Live Trading button, or Simulated Trading button, to accept and open either a blank workspace, or the workspace(s) previously opened.
4. If no workspace is open, simply use the sequence File → New → Workspace, and create a new workspace.
Step 2: Open Chart with Data
1. Now that you have an empty workspace, you need a chart showing data. So, click on the Chart Analysis icon in the Vertical Toolbar on the left of your screen. It should look like eps or eps . That will bring up a default chart with the default symbol.
That’s it. You’re off to the races.
Now, to stay consistent with the data in this book, let’s display the symbol DIS (Disney). If you want to use the same time frame as I’m using, simply go to www.moneymentor.com/TSME/DIS.txt and download the data. From there you can import the data into TradeStation. Or, if you want to use current data, simply type the letters DIS and TradeStation will display the data it has for Disney.
By default, my version of TradeStation brings up a 5-minute chart. I want to display daily data, so I simply click on the little clock in the horizontal toolbar near the top of the screen. It looks like this: eps . Then select the Daily time frame from the pull-down menu.
You should now have a chart that looks something like the one in Figure 2.2.
FIGURE 2.2 Your First Chart
ch02fig014.epsWasn’t that easy?
If your chart shows up black, with white bars, don’t worry. I’ll teach you how to make it look more like mine later on.
Step 3: Crank Up the PowerEditor (Open EasyLanguage)
All we need to do now is put these pseudo-programming steps into the computer (TradeStation and EasyLanguage) code. To do this, we simply open the EasyLanguage PowerEditor and go to it. Right?
Well, not exactly. When you open a TradeStation chart, you are at a fork in the road. When you go to the EasyLanguage PowerEditor, you are at another fork in the road. You must make a choice. In the words of the famous Yogi Berra, When you come to a fork in the road, take it.
Let’s look at all the forks.
If you are not already looking at the EasyLanguage PowerEditor, simply look again at the Vertical Toolbar on the left, and click on the EasyLanguage icon. It looks like this: eps . Or, in version 9, like this: eps . This will bring up a menu of choices: either Open EasyLanguage Document, or New EasyLanguage Document. The New...
selection has more choices. As you can see if you hover over the selection, it will bring up lots more choices, shown in Figure 2.3.
FIGURE 2.3 Menu Sequence to Start a New Indicator
ch02fig015.epsFor now, choose the sequence New EasyLanguage Document → Indicator. This will open a new blank window for you, upon which you can begin to type EasyLanguage Reserved Words, functions, variables, and general code. But before you can actually get to the blank window, you must give it a name and choose which programs it will be available to, and choose a template (or none) for the code it lays down.
FIGURE 2.4 Naming Your Indicator
ch02fig016.epsIt is sufficient to give it just a simple name and click OK. You’ll get something to begin working with.
A note about naming conventions: There are already names of indicators from A to Z in TradeStation. And, over time, you will download files from TradeStation.com and from vendors. How are you going to find your documents if you name them similarly? To make finding my files easy, I always start my EasyLanguage documents (indicators, functions, strategies, etc.) by prefacing them with my initials and an underscore. For instance, my moving average code would be named sjh_MovingAvg.
That way, all of my code ends up at the same place, and is easily identifiable. (See Figure 2.4.)
Next, we’ll see how to put some code in this blank window.
Routine Types
Before writing our first code sample, you must know the different types of routines available within EasyLanguage. There are several types of routines to choose from (and from time to time they add more), and they each serve a different purpose. In this book we will address only Functions, Indicators, PaintBars, ShowMes, and Signals. There are more routine flavors in EasyLanguage (EZL), but those are best left to the advanced EZL books.
Each of these routine types has its own set of requirements, as to inputs and outputs. And, each type of routine serves a unique purpose in TradeStation.
Let’s briefly look at two routine types, to give you an idea of what they are and how they are distinguishable. The additional routine types will be covered more in depth in Chapter 4, Basic Use of TradeStation.
Indicator
An indicator plots data on a chart.
For the moment, let’s go back to the Chart Window. If you don’t already have a chart window open, with DIS daily data on it, then open a chart in your TradeStation window, and put some data on it. Without data, you can’t have a chart, and without a chart, you can’t have an indicator.
Your chart still looks like Figure 2.5, from Figure 2.2 above.
Now click on the Insert menu item and pull down to Indicator. Click (or use the ALT+C control sequence). For this exercise, choose the Mov Avg 1 line
indicator supplied with the software (as seen in Figure 2.6), and click OK. (See Figure 2.6.)
FIGURE 2.5 Your First Chart
ch02fig017.epsFIGURE 2.6 Pull-down Menu
ch02fig018.epsAccept the default input parameters by clicking OK (Price = Close and Length = 9), so we can get right to the issue at hand—plotting something on a chart. My chart now looks like Figure 2.7 with the data and a smooth (thin) cyan line that sort of follows the data. That cyan line is a plot. Of course, in this book the cyan line is gray.
FIGURE 2.7 Chart with a Moving Average Plot
ch02fig019.epsThe moving average line on this chart is very difficult to see. By default, it is a thin, solid line and is a light color. We can change all of that. But, for now we are going to keep moving forward; later we’ll enhance the look of the display.
Plot 1 …
In olden times TradeStation allowed only four plots on one window. Nowadays you may have as many as 99 plots in any one indicator. You may base the plot on any of the four elements of price (open, high, low, or close), and you may calculate just about anything you can imagine to be plotted. As your coding gets more sophisticated, you can manipulate the plot by varying colors, line thickness, and other style aspects of the plot.
What about volume? That’s not considered part of the data of a bar. It is an indicator, plotted by inserting an indicator called Volume.
The Plot Reserved Word has the format:
PlotN(Expression[,
[,ForeColor[,Default[,Width]]]]);
where N may range from 1–99
Expression is the value or formula for the value to be plotted
PlotName in quotes gives the plot a textual name with which you can identify it later
and the rest of the values are optional and will be discussed later.
One thing to keep in mind: While the software is versatile enough to allow 99 plots on one chart, you can’t realistically distinguish more than about 7, so don’t overdo putting plots on one chart.
Now let’s make some changes to our simple indicator.
Step 4: Write an Indicator
Previously you looked briefly at the EasyLanguage PowerEditor. You were confronted with a blank window and not a clue as what to do.
Let’s go back to that step and open the code for the simple moving average we placed on the chart in Figure 2.7. Here are the quick steps:
1. Click on the EasyLanguage icon and pull-down to Open EasyLanguage Document, from the vertical menu bar on the left of your screen.
2. Select Indicator from the Select Analysis Type selection box, as shown in Figure 2.8.
FIGURE 2.8 Open EZL Indicator
ch02fig020.eps3. Scroll over and select the Mov Avg 1 Line indicator (see Figure 2.9) from the list of indicator names, and click Open.
FIGURE 2.9 Select Mov Avg 1 Line
ch02fig021.eps4. TradeStation will open a new window with EasyLanguage code in it. The code, which is as yet undecipherable to you, looks like that in Figure 2.10.
FIGURE 2.10 Your First Look at EasyLanguage Code
ch02fig022.epsEasyLanguage code is composed largely of Reserved Words, arithmetic operators, variables, inputs, and comments. The most significant line of code in this EZL document is:
Plot1[Displace] (Avg, Avg
);
The Displace
variable is optional, so let’s take it out. Now the line just looks like this:
Plot1(Avg, Avg
);
Avg is the data we want plotted, one data point at a time. Avg
is the name we give to the data stream to identify it. That’s all there is to it. Except for one more, very important piece of information.
The semicolon tells EZL that our sentence
is complete. Each complete thought, or sentence, or command (whatever you want to call it) must be terminated with a semi-colon (;).
If you forget to terminate your sentence with the semicolon, you will get an error message from EZL. Sometimes it will say you forgot the semicolon; sometimes it will tell you that it a variable name is undefined; and sometimes it will say something else. It all just means that EZL cannot decipher your sentence until it comes to the next semicolon.
Don’t worry about the rest of the code. Most of it is extraneous, and is used for more esoteric applications. The only code you need in your indicator is this:
inputs: Price( Close ), Length( 9 );
variables: Avg(0);
Avg = Average (Price, Length);
Plot1( Avg, Avg
);
We can simplify the code even further, if we don’t yet care about variables and inputs. The most basic EZL code for a simple, one-line moving average is:
PLOT1(Average(C,9),MAV1
);
Aside: Moving Averages
In every seminar¹ I teach I find that several people don’t know what a moving average is. That’s OK. You probably only know that sort of thing if you are a math major or engineer or scientist of some kind. For those who don’t recognize this terminology, it will be explained in Chapter 5, Basic Math. Basically, just know that it is a string of numbers which are calculated by averaging together a selection of numbers and then moving forward in the list and averaging the next selection.
Conventions
By convention, I like to put my initials in front of the name for all routines I write. That way, when I search for my work later, it is all alphabetized under sjh_
in a group, rather than being scattered among TS’s built-in indicators or indicators I have purchased from TS solution providers. Therefore, I would likely name our new indicator sjh_ MAV1.
You may name it anything you wish.
After making the above changes to your code, go up to File and pull down to Save As (see Figure 2.11). Look carefully, because there are other Save As commands to save your workspace and your desktop as well as your EasyLanguage Document.
Select Save EasyLanguage Document As... and give your document a new name.
In the Name
box type the name you have chosen for this indicator. You do not need to fill in Short name
or Notes
at this time. Now click OK.
FIGURE 2.11 Mov Avg 1 Line
ch02fig023.epsThat’s it. You did it! Later on I will explain to you what all those strange words meant. For now, I just want you to see the process from beginning to end.
The only other thing you have to do is to Verify the code. That’s the next step.
Code Verification
Before TradeStation will allow you to use a routine on a chart, it wants to make sure that you haven’t made any blatant coding errors. Thus, the EasyLanguage PowerEditor will check the syntax of your code for you, so you don’t spend tremendous amounts of time debugging.
To verify your code, you may either press the eps key, click on the verify icon eps , or use the File → Verify menu sequence. If your code is syntactically correct, TS will first say Verifying
and then respond with Verification Successful.
Back in the way back, EasyLanguage used to respond with Excellent!
and it was thrilling and encouraging. Once they became a securities company, it had to get rid of that response, as it might be misconstrued as an indication that your code might be profitable. Now it’s just a simple Verification Successful,
not even an exclamation point.²
If your verify is not successful, go back and check each and every semicolon, space, and comma until your code looks just like mine and your verify gives you … successful.
Now you have written an indicator with the PowerEditor.
Step 5: Putting an Indicator on the Chart
To see your new indicator, you need to put it on the chart. In the previous step we put a built-in indicator on your chart, just so you could quickly see what an indicator was. If you haven’t already, take that indicator off your chart. You will do so by selecting the plot and pressing the Delete key eps .
When you click on the indicator on your chart, be sure to place your cursor (the point of the arrow) right on top of the indicator line. When you click, little black boxes will appear at intervals on the indicator (see Figure 2.12). This means that you have actually selected the indicator. If the little black boxes don’t appear, you haven’t yet clicked in exactly the right spot.
FIGURE 2.12 Chart with Built-in Indicator Selected
ch02fig024.epsPressing the Delete key while the black boxes are showing on the indicator will remove the indicator from your chart.
Now you can put your new indicator on the chart, using the Insert Indicator pull-down menu shown in Figure 2.13.
FIGURE 2.13 Insert Indicator
ch02fig025.epsGo to Insert on the upper, horizontal menu bar and pull down to Indicator and click. This will bring up a list of all the indicators available to you. Select the one we just created and click on its name. This will place the indicator plot on the chart.
Experiment with taking that indicator off the chart and putting new indicators on the chart. With each indicator, take a look at what is true
of the indicator in relationship to the movement of the underlying market. What happens to the indicator, for instance, when the market changes direction? Is there anything that you could use to pinpoint highs and lows or turning points?
Your chart window should now look like mine, shown in Figure 2.12. Again, the moving average is in subgraph two.
Step 6: Write a Strategy
A strategy could also be called a recipe, a map, a procedure, a system, or a method. A strategy is an algorithmic approach to trading and does not involve guessing or intuition.
A strategy, therefore, is a set of steps that are followed precisely each time you wish to evaluate whether to buy or sell.
In TradeStation 4.0, a system is created in a single routine, which examines each and every bar of your chart to see whether your buy or sell conditions are met. This routine is called a system in TradeStation 4.0.
In TradeStation 2000i, a system is called a strategy