31.07.2021 Views

Ultimate Algorithmic Trading System

Using automated systems for trading in stock markets

Using automated systems for trading in stock markets

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

218

AN INTRODUCTION TO EASYLANGUAGE

through all the lines in the block. If the current market position is 1 or long, then

TradeStation in instructed to exit the long position if one of two criteria are met:

1. If myBollingerB > (1 – triggerVal) or 0.8, then the long is liquidated on the next

bar’s open.

2. If the difference between the current close price is less than the entryPrice –

2000/bigPointValue, then the long is liquidated on the next bar’s open.

The short liquidation occurs in a similar manner. If myBollingerB < 0.2 or the

close is greater than the entryPrice + 2000/bigPointvalue. That’s the entire mean

reversion system that we introduced in Chapter 3.

Another key and cool feature of EL is that all variables are special arrays. When

you declare the variable myBollingerBand in the vars: section, you are informing

the compiler to create an array with the name myBollingerBand. This is a

special array because you don’t need to worry about keeping track of the values

in the array. The value is carried over from one bar to another until it is changed.

Because myBollingerBand is an array, you can access the prior bar’s value by

indexing the variable name. The prior bar’s myBollingerBand value is accessed

by myBollingerBand[1]. These variables can be referred to as bar arrays.

Once you type your code in and want to see if it Verifies or compiles, all you

need to do is go up under the Build menu and select Verify. If all goes well, you

will see this dialog (Figure 7.11).

If not, then you might see what’s in Figure 7.12. TradeStation is politely informing

you that you have made a syntax error. If you double-click on the error, the EL

Editor will take you directly to the offending line with the error. The error message

also informs you of the line number. If you want the EL Editor to show line numbers,

go under the Tools menu and select Options. A dialog window like the one in

Figure 7.13 will open.

Click on Line Numbers. The EL Editor has added the capability of grouping

strategies, indicators, and functions together in a neat package known as a Project.

If you build a strategy that calls in a lot of external functions, then putting the strategy

FIGURE 7.11 A message confirming that your code was verified and will be recalculated based

on the new inputs.

www.rasabourse.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!