TradeStation EasyLanguage Tutorial
Multiple Output Functions
In this TradeStation EasyLanguage Tutorial we will show one of the most powerful methods in TradeStation EasyLanguage, which is developing multiple–output functions using by ref parameters. This concept allow you to write very reusable functions and we will use several TradeStation functions in our example.
EasyLanguage ® is a full-featured programming language designed for traders. EasyLanguage ® can be used to create powerful trading indicators, strategies and custom trading applications. Graphical inputs are essential: color, width, etc. We hope this EasyLanguage tutorial was useful for you. You can use this information to create indicators or trading systems with TradeStation and MultiCharts. Do you want to learn EasyLanguage & PowerLanguage for TradeStation and MultiCharts? Start here: EasyLanguage & PowerLanguage Master Tutorial. EasyLanguage® documents (analysis techniques, strategies, and functions) include statements that allow you to access market data from analysis windows (charts and grids) and to control logic that can plot information and manage your trading rules. This help file includes topics about.
We offer this class in computer-lab environments, providing you with a computer to use, with TradeStation already installed. This gives you a true hands-on opportunity to learn the essentials of EasyLanguage and how to use them in developing your own custom strategies and analysis techniques. To do this we will use the reserved word in easylanguage “TestNew”. The indicator will follow the trend of a 14-period RSI and will signal the OverBought and OverSold areas. Insert the Lenght for the RSI calculation – 14 is the standard value.
A basic user function framework
User functions are used to make reusable calculations, for example to calculate indicator values, sorting, and so on. User functions have input parameters. These parameters can be either input parameters or input/output parameters. These parameters can also have various types. Some of these types are NumericSimple, NumericSeries, NumericRef, StringSimple, numericarrayref, numericarray, and StringRef.
A function can return a single value, but when we use byref, we can return many values from a function. Let’s look at several function shells. ByRef passes the memory address of a variable which we can then fill the contents of that memory address within the user functions. That is how byref works. Normal parameters, such as NumericSimple, NumericSeries, and Stringsimple all just copy the contents to an address on the function stack. This means it can copy data into the function but can not modify the values that are passed in. Only the variable types with Ref suffix can be modified.
Let’s first look at a simple moving average function:
We can see that we can pass a price series. This series can be a scalar or a system for example Close, High or (Close+High+Low)/3 which would be a scalar which will be passed though and converted to a numeric series. We also have the Length parameter which is a simple numeric value. Another interesting thing about this function is the use of the error trapping routine for divide by zero.
Let’s now look at a simple example of using input/output variables.
This is a very powerful concept. In TradeStation, the best example of how to use this concept is in the linear regression functions:
This function gives us all of the variables that are used in regression models. Let’s look at the inputs for this function:
We can see that we can predict any number of bars in the past or future, we can return the slope, angle, intercept and the value. This allows this one piece of code to be used for many wrapper functions as well as in more complex models and systems and only do these calculations once. Let’s look at an example of how TradeStation used this in a wrapper. Let’s first look at the complete linear regression function.
Easylanguage Essentials Pdf
We will now create a linear regression slope function which uses the multiple output function from above. This is an example of creating these super functions and using wrappers to use them for multiple purposes.
I hope this tutorial has explained how to use byref and make functions which return multiple outputs and how they can be used to simplify developing complex code and make valuable reusable functions.
EasyLanguage® is a full-featured programming language designed for traders. EasyLanguage® can be used to create powerful trading indicators, strategies and custom trading applications. EasyLanguage® unleashes the power of the TradeStation platform by extending the ways you can view our extensive real-time and historical market data, as well as account, position, and trade manager information. With thousands of built-in keywords, functions, and properties, developers can design and create virtually any market analysis, scanning, or order management tool.
Easylanguage Essentials
Watch the TradeStation Development Environment (TDE) introduction and overview: