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.

on the next bar’s open. The only difference is the close must be below the 200-bar

moving average and the 3-bar moving average of the myBollingerB variable

must be greater than 1 - triggerVal.

There is a lot going on with this code. Any time you use the keyword if

it must be eventually followed by the keyword then. Initiating long positions

requires the keyword buy and short position requires the keywords sellShort.

You can give names to your entry and exit signals by following the keywords

Buy/SellShort/Sell/BuyToCover with the name of the signal enclosed within

quotes and parentheses. The buy signal is this example is ‘‘LongReversion’’ and

the short signal is named ‘‘ShortReversion.’’ This isn’t necessary but it does help

when you have multiple entry and exit signals. EL requires you to use the words

next bar or this bar on/at close whenever you direct TradeStation to initiate or

liquidate an existing position. When programming in EL, think of yourself sitting

in front of the computer screen right at the close of a bar. You can place a market

order immediately and get filled at the current close, you can place a market order

and get filled at the next bar’s open price, or you can place a limit or stop order for

the next bar. By limiting you from seeing the next bar (other than the open price),

TradeStation eliminates all risks of ‘‘Future Leak.’’ In other words, you cannot peek

into the future by looking at the next bar and make a trading decision on the current

bar. Both the VBA and Python back testers allow you to do this, not in order to

cheat, but to allow complete testing flexibility.

Take a look at the next section of code and see if you can tell what is going on.

If marketposition = 1 then

begin

end;

If myBollingerB > 1 - triggerVal then sell("L-Exit")

next bar at market;

If c <= entryPrice - mmStop/BigPointValue then

sell("MML-Exit") next bar at market;

If marketposition = -1 then

begin

end;

if myBollingerB < triggerVal then buyToCover("S-Exit")

next bar at market;

if c >= entryPrice + mmStop/BigPointValue then

buyToCover("MMS-Exit") next bar at market;

217

AN INTRODUCTION TO EASYLANGUAGE

In Python, the keyword then would be replaced by the colon (:). Since the code

controlled by the if consists of more than one line of code, the keywords begin and

end must be used to encapsulate the code. For every begin there must be an end.

The begin and end informs the compiler that the code is related and must flow

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!