Sunteți pe pagina 1din 26

Introduction to

EasyLanguage

TradeStation

Introduction to EasyLanguage
1




Important Information and Disclaimer:

TradeStation Securities, Inc. seeks to serve institutional and active traders. Please be advised
that active trading is generally not appropriate for someone of limited resources, limited
investment or trading experience, or low risk tolerance, or who is not willing to risk at least
$50,000 of capital.

This book discusses in detail how TradeStation is designed to help you develop and test trading
strategies. We offer you unique tools to help you design your own strategies and look at how
they could have performed in the past. While we believe this is very valuable information, we
caution you that simulated past performance of a trading strategy is no guarantee of its future
performance or success. We also do not recommend or solicit the purchase or sale of any
particular securities or securities derivative products. Any securities symbols referenced in this
book are used only for the purposes of the demonstration, as an example; not a
recommendation.
Finally, this book shall discuss automated electronic order placement and execution. Please
note that even though TradeStation has been designed to automate your trading strategies and
deliver timely order placement, routing and execution, these things, as well as access to the
system itself, may at times be delayed or even fail due to market volatility, quote delays, system
and software errors, Internet traffic, outages and other factors.

All proprietary technology in TradeStation is owned by TradeStation Technologies, Inc., an
affiliate of TradeStation Securities, Inc. The order execution services accessible from within
TradeStation are provided by TradeStation Securities, Inc. pursuant to a technology license
from its affiliate and its authority as a registered broker-dealer and futures commission
merchant. All other features and functions of TradeStation

and EasyLanguage

are registered
trademarks of TradeStation Technologies, nc. "TradeStation, as used in this document, should
be understood in the foregoing context.

Option Risk Disclosure

Option trading carries a high degree of risk. Purchasers and sellers of options should familiarize
themselves with option trading theory and pricing, and all associated risk factors. Please read
the Characteristics and Risks of Standardized Options available from the Options Clearing
Corporation website: http://www.optionsclearing.com/publications/risks/riskstoc.pdf or by writing
TradeStation Securities, 8050 SW 10 Street, Suite 2000, Plantation, FL 33324.

Copyright 2002-2009 TradeStation Technologies, Inc. All rights reserved. Licensed to its
affiliate, TradeStation Securities, Inc. (Member NYSE, FINRA, NFA and SIPC)

Introduction to EasyLanguage
2

Table of Content

What is EasyLanguage? ............................................................................................................ 3
What are the benefits of learning EasyLanguage? ..................................................................... 3
Available Market Data ................................................................................................................ 3
The TradeStation Development Environment ............................................................................. 4
Creating New EasyLanguage Documents .................................................................................. 4
Dictionary Slide Bar ................................................................................................................... 6
The EasyLanguage Output Bar .................................................................................................. 6
EasyLanguage Expressions and Statements ............................................................................. 7
EasyLanguage Punctuation ....................................................................................................... 7
Plot Statements .......................................................................................................................... 8
Inputs ......................................................................................................................................... 8
Mathematical Operators ............................................................................................................. 9
Referencing Data from Previous Bars ........................................................................................ 9
Using Functions ........................................................................................................................10
Writing Alerts in EasyLanguage ................................................................................................11
ShowMe Studies .......................................................................................................................11
Strategies ..................................................................................................................................12
EasyLanguage Order Syntax for Strategies ..............................................................................12
You don't have to reinvent the wheel ........................................................................................13
What's next? .............................................................................................................................13
APPENDIX ................................................................................................................................15

Introduction to EasyLanguage
3

What is EasyLanguage?

EasyLanguage is a combination of words, operators and punctuation used to create rules or
instructions, based on market data, which TradeStation follows to perform one or more
analytical tasks.

EasyLanguage is designed to use simple English-like terms that one trader would use to
describe a trading idea to another trader. There are certain rules and guidelines we must follow
to ensure that the EasyLanguage studies we create can be understood by and applied within
TradeStation. Using the correct grammar, statement structure, and punctuation is a must when
creating custom EasyLanguage documents. We encourage you to follow these rules from the
start to facilitate your learning curve.

What are the benefits of learning EasyLanguage?

x With EasyLanguage, you can translate your trading ideas into analysis techniques and
strategies that TradeStation can understand and apply
x You will have the ability to edit and modify the EasyLanguage of built-in analysis
techniques and strategies
x In addition, it allows you to read, understand, and learn from what others have written
x Learning EasyLanguage will provide you with an understanding of the calculation
intricacies of technical analysis and strategy trading

Available Market Data

Each bar on a chart contains a certain amount of raw data for analysis. The following is a list of
the data contained in each bar of a chart, depending on the type of symbol and interval
selected:

x Date
x Time
x Open
x High
x Low
x Close
x Volume
x Ticks
x Futures Open
Interest
x Implied Volatility
x Option Volume
x Option Open
Interest
x Fundamental Data

As you work with EasyLanguage, one of the basic principles to remember is that TradeStation
calculates analysis techniques and strategies on each bar. TradeStation processes all
EasyLanguage instructions from top to bottom (as written in the TradeStation Development
Environment) starting from the first bar on the left side of a chart and repeating the instructions
for each bar as it moves to the right.





Introduction to EasyLanguage
4

The TradeStation Development Environment

Whenever you create or modify
EasyLanguage studies in TradeStation, you'll
be working in the TradeStation Development
Environment. Think of it as your canvas and
analogous to the way you would use
Microsoft Word to create and edit Word
documents. The TradeStation Development
Environment is a full-featured "word-
processing editor for creating and modifying
EasyLanguage instructions that lets you
communicate your trading ideas to
TradeStation. New analysis techniques may
be created or existing ones may be modified,
including indicators, ShowMe and PaintBar studies, as well as rule-based strategies.

The TradeStation Development Environment is also conveniently designed as a stand-alone
application to run independently from the TradeStation platform. A new icon, such
as the one on the left, is now available when clicking Start - All Programs from the
Windows task bar. You may also click the EasyLanguage icon from the Shortcut
Bar within TradeStation to launch the Development Environment.


Creating New EasyLanguage
Documents

To create a new analysis technique or
strategy in the TradeStation Development
Environment, click File - New menu
sequence and choose the type of
EasyLanguage document you would like to
create from the drop-down menu.

You may also click the New button, which is
the first button displayed on the toolbar.
The button has two clickable areas; clicking
the white page will open the same type of
EasyLanguage document used previously,
clicking the arrow will drop a menu allowing
you to choose the type of EasyLanguage
document you want to create.

An indicator in TradeStation may be defined
as a mathematical calculation using the data from each bar, and then plotting the calculated
value for each bar on the chart. Indicators are generally plotted on charts as either a line or
histogram.


Introduction to EasyLanguage
5

The three main areas of the TradeStation Development Environment are the Editor, the Output
Bar, and the Dictionary.

x EasyLanguage Editor Is launched when a new EasyLanguage document is created
or an existing one is opened.

x EasyLanguage Output Bar A desktop bar that returns information about the
EasyLanguage document. By default, the Output Bar is displayed at the bottom of the
Development Environment.

x EasyLanguage Dictionary A reference dictionary of EasyLanguage words, functions,
etc. The Dictionary is displayed as a retractable bar on the right.





In addition to providing common word-processing features and color-coding for various
elements of EasyLanguage, the Development Environment also checks for proper syntax and
grammar.





Editor
Dictionary
Output Bar
Introduction to EasyLanguage
6

Dictionary Slide Bar

On the right side of the Development
Environment, a button labeled Dictionary
will give you access to the EasyLanguage
Dictionary slide bar. The Dictionary can be
a tremendous help while editing or creating
strategies and analysis techniques.

Clicking any of the categories listed in the
left pane will list elements from that
category on the top right pane. You may
also search for reserved words or
functions, by typing them in the Search
field, and clicking the green arrow button or
pressing Enter on the keyboard. A list of
all matching or related EasyLanguage
reserved words or functions will appear.
Highlighting one of the words will display a
short summary and example in the bottom
right pane.

Words and functions can be dragged and
dropped directly into the EasyLanguage
code. The picture on the left displays the
results after searching for the word "time.
The EasyLanguage Dictionary slide bar
simplifies the process of searching and
finding the reserved words or functions
needed for your code.


The EasyLanguage Output Bar

The EasyLanguage Output Bar enables you to find errors easily and quickly so you can resolve
them. Verification ensures the EasyLanguage commands used to create an analysis technique
or strategy follow the EasyLanguage rules. If an analysis technique or strategy contains syntax
errors, these errors are recorded in the EasyLanguage Output Bar for further evaluation.

Tip: The EasyLanguage Output Bar appears docked at the bottom of the
TradeStation Development Environment; however you can also float the bar and
move it to any location inside or outside the Development Environment.




Introduction to EasyLanguage
7

EasyLanguage Expressions and Statements

Words are the basic building blocks of any language. However, to become fluent in a language
requires properly using groups of words to form expressions and, ultimately, statements.
Statements are comprised of expressions, like the phrases in a sentence. All EasyLanguage
instructions or rules consist of statements, which are like sentences in spoken language.
Sentences can express one simple thought or a series of thoughts.

EasyLanguage Punctuation

A critical step in becoming fluent in EasyLanguage is to gain a thorough understanding of its
punctuation. Below is a reference to the most common uses of EasyLanguage punctuation.

( ) Parentheses Used in statement structures for syntax and also
algebraically for grouping mathematical operations.

Quotes Denote a text item (e.g., "plot name) in EasyLanguage.

; Semi-colon Indicates the end of a statement.

: Colon Denotes the declaration of a list.

, Comma Separates items in a list.

[ ] Square brackets Used to reference data from a previous bar and to
displace a plot. Also used in arrays.

{ } Curly brackets Any text between curly brackets is notation (remarks)
that is not part of the EasyLanguage instructions.

// Double forward slash Any text following a double forward slash, for the
remainder of that line only, is notation (remarks) and not part of the
EasyLanguage instruction.

Line returns, line spacing, and paragraph indents are ignored by EasyLanguage and are
generally used for improved readability of the code only; they do not affect the EasyLanguage
instructions.





Introduction to EasyLanguage
8

Plot Statements

Plot statements instruct TradeStation where to draw plots in a Chart Analysis window, or what to
place in a cell in a RadarScreen window. They are used for TradeStation indicators, ShowMe
and PaintBar studies. An analysis technique may contain a maximum of 99 simultaneous plot
statements.




Inputs

An input is a user-editable value used in an analysis technique or strategy. It is a place holder
which allows the user to change a value from the Inputs tab of the Format dialog. This
provides flexibility and efficiency when modifying analysis techniques and strategies.

The figure below shows the Input tab in the Format Indicator dialog for TradeStation's RSI
indicator. As you can see, six inputs are specified and can be changed directly from this dialog.



So if you decided to change the Length used in the RSI calculation, or the numeric levels
indicating OverBought and OverSold conditions, you could easily modify the indicator without
having to return to the EasyLanguage Development Environment to do so.

Example:

PIot1 (Open, "The Open");

The word Plot1 in the sample plot statement above states that this
is the first plot for this analysis technique. In this example,
TradeStation is being instructed to place a plot at the Open for each
bar.

"The Open is the plot name and is optional when writing a plot
statement. Assigning a name to a plot, will help you identify a
specific plot when formatting.
Introduction to EasyLanguage
9

Mathematical Operators

EasyLanguage can perform addition, subtraction, multiplication and division and these
mathematical operators may be used to perform calculations within analysis techniques and
strategies.




In a mathematical expression that includes addition, subtraction, multiplication, and division,
TradeStation calculates arithmetic operations as follows: Multiplication and Division, from left
to right followed by Addition and Subtraction, from left to right. This order may be customized
by use of parentheses. Operations inside parentheses are done first, starting with the
innermost parentheses and working outward.

Referencing Data from Previous Bars

Previously occurring prices and other values may be referenced using square brackets, [ ],
immediately following the name of the value to be referenced.






Example:

The close of the bar 5 bars ago would be written:

Close[5]

The Range of the bar 12 bars ago would be written:

High[12] - Low[12]

or

(High - Low)[12]

but not

High - Low[12]

The above formula would subtract the low of 12 bars ago from
the current bar's High.

Addition Subtraction Multiplication Division
*
+
/
Introduction to EasyLanguage
10

Using Functions

Functions are frequently used formulas or comparisons written in EasyLanguage. They may be
called for use in any analysis technique or strategy with just a few words, eliminating the need to
re-create or repeatedly re-type complex formulas.

The EasyLanguage Dictionary includes hundreds of functions that you may use as you write
your own EasyLanguage. Here you will find prewritten functions for RSI, ADX, DMI, Stochastic
and many more. This will save you time and make your instruction more efficient.










Example:

Let's say you wanted to calculate a 10 bar moving average.
You could type the following to accomplish this:

Value1 = (Close + Close[1] + Close[2] +
Close[3] + Close [4] + Close[5] + Close[6] +
Close[7] + Close[8] + Close [9]) / 10;

Typing the words that call the Average function, Average
(Price, Length), would accomplish the same task much more
quickly and efficiently. When using functions it is necessary to
provide values for the parameters in parenthesis. So, if you
wanted to use the Average function based on the closing price
and a Length, or number of bars of 14, it would look like this:

Average (Close, 14)

Introduction to EasyLanguage
11

Writing Alerts in EasyLanguage

Alerts are audio-visual or electronic notifications of specific market events as defined by the
user.

x Alerts are only triggered when criteria are true on the last bar of a chart.
x The EasyLanguage instructions for the analysis technique must contain the alert
criteria.
x Alerts must be "enabled for the analysis technique, either by default setting in the
EasyLanguage Development Environment or in the Format dialog.

The last two bullet points above are extremely important when working with alerts, especially
when writing your own into EasyLanguage documents. Because an alert is usually contingent
on an event, EasyLanguage alert instructions are written using "f.then statements.




ShowMe Studies

A ShowMe study marks each bar on a chart that meets specific criteria. These studies are used
for identifying historical occurrences, as well as monitoring for current occurrences, on a chart.
Generally, ShowMe studies are not used to mark all the bars on a chart but rather only those on
which some condition is true.




Example:

PIot1 (High, "Momentum Increasing");

The word Plot1 in the sample plot statement above states that
this is the first plot for this analysis technique, in this case a
ShowMe study. High is the location on the y-axis where the
plot will appear if the condition is true. In this case, the
ShowMe will mark the high of the bar. "Momentum ncreasing
is the plot name.

Example:

If Close > Highest (Close, 10)[1] then
Alert;

n English this translates into, "f the close is greater than the
highest close of the last 10 bars starting 1 bar ago, then alert.

Introduction to EasyLanguage
12

Strategies

A trading strategy monitors the market for past and current occurrences of criteria that are
position entry and exit points. These occurrences are indicated on a chart and logged for
performance reporting purposes. Current occurrences of trading criteria may also be sent to the
marketplace for actual execution.

EasyLanguage Order Syntax for Strategies

EasyLanguage uses four trading verbs to identify the market action to be taken in a strategy:

x Buy: establish, or add to, a long position (any existing short position will be covered
before a long position is established)
x SellShort: establish, or add to, a short position (any existing long position will be
liquidated before a short position is established)
x Sell: sell to liquidate a long position only
x BuyToCover: buy to cover a short position only

Note: These four verbs act as described above regardless of the symbol to which the
strategy is applied. That is, the verb SellShort must be used to generate short positions
even if the strategy is applied to a futures or forex symbol.

These actions may be taken in the following ways:

x Next bar at market = on the Open of the next bar
x Stop = on the next bar if the stop is triggered
x Limit = on the next bar if the limit price is reached
x This bar on close = on the Close of this bar (for backtesting only)



Examples:

If true/false expression then
Sell Short next bar at market;

Sell next bar at Close of this bar + .10 limit;

Buy to Cover next bar at High of this bar + .05 stop;

Limit and Stop orders may also reference the Open of the next bar in
the limit or stop prices.

Buy next bar at Open of next bar - .05 limit;
Introduction to EasyLanguage
13

You DRQW Have to Reinvent the Wheel

As you know, TradeStation comes with dozens of on-board analysis techniques and strategies
including indicators, and ShowMe and PaintBar studies. All of these, of course, are written in
EasyLanguage. In addition, TradeStation is an open-development platform, allowing you to
view (or modify if you choose) any pre-existing analysis techniques by simply opening them in
the Development Environment. This provides users with a great learning benefit. By viewing
pre-written EasyLanguage studies in TradeStation you may:

x Gain an understanding of how and why a certain study behaves the way it does
x Reduce the EasyLanguage learning curve
x Generate additional analysis ideas

Should you decide to modify any existing analysis techniques, it is always best to save the
changes with a different name, thereby preserving the original file for later reference and
use.

:KDWV1ext?
EasyLanguage Boot Camp can open up a host of
possibilities in your strategy testing and trading. Whether
you want to create your own strategies and techniques
from scratch, modify existing ones or simply desire a
fluency in EasyLanguage to better understand the work of
authors and developers, this is the course for you.
EasyLanguage Boot Camp is a two-day class designed to
provide a solid working knowledge of EasyLanguage, with
strong emphasis on practical information you can use right
away. Our instructors will guide you step by step through
exercises that cover creating strategies, indicators, and
ShowMe and PaintBar studies, including studies
designed specifically for use with RadarScreen.
Mastering EasyLanguage for Strategies is a 2-day
class specifically designed to follow the material covered
in the EasyLanguage Boot Camp class. The purpose is to
delve more deeply into using EasyLanguage for accomplishing a variety of tasks in creating,
testing and automating strategies. Topics include EasyLanguage specifically designed to take
advantage of Intrabar Order Generation, multi-data analysis, scaling out of positions, tying exits
to entries, and much more. The teaching method will be familiar to those who have been
through our other EasyLanguage classes: a task-oriented approach using practical examples.
The LiveOnTheWeb version of these classes is delivered online; it is suited for your busy
schedule and you may attend from the convenience of your home or office. The Live in-person
version of this class is delivered in a computer-lab environment, providing you a true hands-on
opportunity to learn EasyLanguage.

Introduction to EasyLanguage
14

EasyLanguage

Home Study Course



This self-paced home-study course is based on our popular
EasyLanguage training classes offered live around the country.
It is designed to teach you EasyLanguage programming,
starting with the fundamentals and continuing through
advanced topics, so that you can create your own trading
indicators and strategies. The EasyLanguage Home Study
Course comes with a CD containing answers to all of the
course exercises and video answers for all the challenge
exercises.






Mastering EasyLanguage

for Strategies Home Study


Course

Mastering EasyLanguage for Strategies Home Study Course is
a self-paced course book based on our popular live 2-day
hands-on Mastering EasyLanguage for Strategies Course. It is
specifically designed to build on the material covered in the
EasyLanguage Boot Camp Course or EasyLanguage Home
Study Course. The goal of this course is to advance your
EasyLanguage skills into new areas of indicator and trading
strategy creation and development.


Introduction to EasyLanguage
15





















APPENDIX






















Introduction to EasyLanguage
16

Exercise 1
Creating an Indicator

This indicator plots a line representing the real body of each candle. The value will oscillate
between positive and negative values.

Real Body = Difference between Open and Close

Indicator: **Real Body








Value1 = Close - Open;

Plot1 (Value1);
Plot2 (0);
Introduction to EasyLanguage
17

Exercise 2
Using EasyLanguage Functions

Modify the Real Body indicator to plot a line representing the average of real body over a user
specified number of bars.

Indicator: **Real Body Avg








Value1 = Close - Open;
Value2 = Average (Close - Open, 10);

Plot1 (Value1);
Plot2 (Value2);
Plot3 (0);
Introduction to EasyLanguage
18

Exercise 3
Using Formulas and Functions as Inputs

You may use any formula or function when formatting the Inputs of any Analysis Technique or
Strategy.

Examples:

( High + Low ) / 2
( Open + High + Low + Close ) / 4
Open Close
Average ( Open Close, 10 )







Introduction to EasyLanguage
19

Exercise 4
Creating Alerts

Modify the Average Real Body indicator to generate an alert every time the average crosses the
zero line.

Indicator: **Real Body Avg








Value1 = Close - Open;
Value2 = Average (Close - Open, 10);

Plot1 (Value1);
Plot2 (Value2);
Plot3 (0);

If Value2 crosses over 0 then
Alert;
If Value2 crosses under 0 then
Alert;
Introduction to EasyLanguage
20

Exercise 5
Creating a ShowMe

This ShowMe will display a dot on the bar that meets specific criteria. In this case it will identify
the bar where the Average Real Body oscillator crosses from positive to negative and vice
versa.

ShowMe: **Real Body Cross







Value1 = Average (Close - Open, 10);

If Value1 crosses under 0 then
Plot1 (Low);

If Value1 crosses over 0 then
Plot2 (High);
Introduction to EasyLanguage
21

Exercise 6
Creating a Strategy

This strategy will generate a Long entry when the Real Body oscillator crosses over the zero
line. It will generate a Short entry when the Real Body oscillator crosses under the zero line.

This strategy is always in the market. Long entries will exit Short positions, and Short entries
will exit Long positions.

Strategy: **Real Body Cross







Value1 = Average (Close - Open, 10);

If Value1 crosses over 0 then
Buy next bar at market;

If Value1 crosses under 0 then
Sell Short next bar at market;
Introduction to EasyLanguage
22

Exercise 7
Modifying Alert Criteria

Most Analysis Techniques in TradeStation have built-in alert criteria. This alert criteria is found
in their EasyLanguage document. You may modify these alert conditions to be alerted
differently.

Indicator alert: RSI




Previous Alert




New Alert




{ Alert criteria }

if MyRSI crosses under OverSold then
Alert ("Indicator entering oversold zone")

else if MyRSI crosses over OverBought then
Alert ("Indicator entering overbought zone");
Introduction to EasyLanguage
23

Exercise 8
Adding Plots to Indicators

You may create and plot other lines to already existing analysis techniques. This is done by
adding plot statements to the EasyLanguage document.

Indicator: RSI




RSI with RSI Average




Inputs: Price( Close ), Length( 14 ), OverSold( 30 ),
OverBought( 70 ), OverSColor( Cyan ), OverBColor( Red ) ;

Variables: MyRSI( 0 ) ;

MyRSI = RSI ( Price, Length ) ;

Plot1( MyRSI, "RSI" ) ;
Plot2( OverBought, "OverBot" ) ;
Plot3( OverSold, "OverSld" ) ;
Plot4( Average (MyRSI, 30) );
Introduction to EasyLanguage
24

Exercise 9
Adding Conditions to a Strategy

Combine strategy criteria to generate orders when multiple technical concepts are triggered
simultaneously. This example demonstrates how to add strategy conditions to pre-existing
strategy components.

In this exercise, edit the strategy so that it buys when the fast average crosses slow average
only if RSI is below a certain overbought level.

Strategy: MovAvg2Line Cross LE







Inputs: Price( Close ), FastLength( 9 ), SlowLength( 18 ) ;
Variables: FastAvg( 0 ), SlowAvg( 0 ) ;

FastAvg = AverageFC( Price, FastLength ) ;
SlowAvg = AverageFC( Price, SlowLength ) ;

If FastAvg crosses over SlowAvg and
RSI(Close,14) > 50 and RSI(Close,14) < 70 then
Buy ( "MA2CrossLE" ) next bar at market ;
Introduction to EasyLanguage
25

Exercise 10
Using RadarScreen

Insert custom analysis techniques into a RadarScreen window and monitor hundreds of
symbols simultaneously for real-time alerts.

Indicator: **Real Body Avg

S-ar putea să vă placă și