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.12

This error message appears if your algorithm does not have enough ramp-up data.

158

USING MICROSOFT EXCEL TO BACKTEST YOUR ALGORITHM

can be properly calculated. You must be careful and make sure you provide enough

ramp-up data for your algorithm. If you don’t, the computer will halt and provide

an error message like the one in Figure 5.12.

This looks like a scary error message but it’s simply telling you that you are trying

to go back further in time than you have specified. The commsn variable is what

the computer will deduct from each round-turn trade. In this example it is set to

100; you can change this to any value you think might be appropriate. This is also

a good area to set up any user-defined variables that you might need to use later in

your code. Let’s say you have a special calculation that uses a constant value, like a

profit objective. You could set this up by using the following code:

rampUp = 5 ’ how many days needed in calculations before trading

commsn = 100 ’ commission per round turn trade

myProfitTarg = 0.02 ’ I just put this line of code in

Later on, in the source code you can use myProfitTarg to help calculate where

a profit might be taken. This is a very good time to mention that VBA, in most

cases, is case insensitive. This means the two variable names, myDayCount and

mydaycount, are one and the same. Ignoring case can cause sloppy-looking code

and difficult readability. It’s good programming etiquette to use the same case

throughout a program. As I have mentioned in a previous chapter, I personally like

using a capital letter in a variable name where a new word begins, but not the first

letter of the variable name. Here are some examples you can use as a template

for your variable names: myProfitTarg, longDayCount, myStopAmt. You

have also got to be careful not to step on one of the keywords that is used by

the ESB. Unlike AmiBroker or TradeStation, VBA will not tell you ahead of time

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!