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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FIGURE 5.1

trading.

Once you define the Bollinger Band routine, you can easily incorporate it into

If you are trying to invoke a function or subroutine and this helper box doesn’t

appear, then you probably do not have the function/subroutine spelled correctly

or it doesn’t exist. All functions and subroutines in the ExcelSystemTester will

be listed and explained in the appendix. All functions and subroutines require

two bits of information: (1) the current bar and (2) how many days back to start

the calculations. In the case of the Highest function, the current bar is i and

the offset is 1. An offset of two starts the calculations the day before yesterday.

Remember, we are working in one big loop and each bar is examined by incrementing

the variable i.

■ Data

148

USING MICROSOFT EXCEL TO BACKTEST YOUR ALGORITHM

Accessing the date, price, volume, or open interest data is accomplished by

using seven different arrays: myDate, myOpen, myHigh, myLow, myClose,

myVol, andmyOpInt. Two more arrays provide access to daily range and true

range: myRange and myTrueRange. Unlike AmiBroker’s array processing, you

must index these arrays to get the data for a particular bar. myOpen(10) is the tenth

bar’s open from the very beginning of the data. myDate(10) is the date of the bar

with myOpen(10) opening price. The arrays are synchronized. All data arrays are

preceded with my—so don’t forget this. Let’s say you want to see if yesterday was

a high pivot of strength one. This is how you would test for this occurrence:

If myHigh(i-1) > myHigh(i) and myHigh(i-1) > myHigh(i-2) then

End if

myHighPivot = 1

Remember, i is the current bar in the loop. So by subtracting 1 you get yesterday’s

bar and subtracting 2 gets the day before yesterday’s bar. If you add 1, then you will

have tomorrow’s data today and you can make a killer trading system. With this

information, you will finally have the Holy Grail in your grasp. On the other hand,

save yourself a lot of time and heartache by not adding—just subtracting. I can’t tell

you how many times a client has come to me with a 90% winning trading idea and I

burst their bubble once they discover they are taking advantage of future leak.Hereis

the best example of future leak: Buy tomorrow’s open if the high is greater than the

open. This obviously is a mistake, but other forms of future leak are more esoteric.

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!