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.

If filterTrade = false then

If close > myTopBand then

Buy this bar on close

If close < myBotBand then

SellShort this bar on close

If marketPosition = 1 and c < myAvg then sell this bar on close

If marketPosition =-1 and c > myAvg then buyToCover this bar on close

Before hitting the TEST button, let’s quickly go over the pseudocode. The only

code that was added was the Boolean (true or false) typed variable filterTrade

and its calculation. On every bar, it is initially turned off. The only way it is

turned on is when the distance in terms of dollars between the upper band and

the moving average exceeds $2,000. If filterTrade is on or true, the trade entry

logic is bypassed, thereby skipping the trade. Why did we just use the top band

and the moving average in our risk calculation? Shouldn’t we use the bottom band

and the average for short trades? One calculation is all that is needed since the

distance between the top band and the average is always the same as the distance

between the average and the bottom band—in this case, two standard deviations.

Ready to hit the test button? Table 2.9 shows the results of version 2 of the

algorithm.

Mission accomplished! Or was it? The maximum drawdown was reduced from

to $381K to $103K—a whopping 73 percent. However, as we all know, reward is

proportional to risk and the total profit dropped from $1.3M to less than $600K, or

more than 50 percent. Was it worth it? What if we used $2,500 risk instead, or what

if....Youcanseehowthisstuffcanbecomeaddictive.Wecould optimize the pertrade

risk amount at the portfolio level or at the individual market level. Does it

make sense to have a different risk level for crude oil than gold? If the equity curve

looks better, why not? We could even eliminate all the markets that show a negative

expectancy. We could work all day on different portfolios and what-if scenarios

and create one great-looking equity curve. But who would we be fooling? If it was

the 1980s or 1990s, the public. If we were unscrupulous and wanted to sell this

miraculous algorithm, we could mislead the public with the guarantee that every

number shown was generated by an exact trading algorithm. The general trading

public of the latter part of the twentieth century didn’t know any better and didn’t

understand the term ‘‘with benefit of hindsight.’’ Nowadays, with the computer

power and data at our fingertips, we would be fooling ourselves because the trading

public now has the same computers and data and has been fully educated on ‘‘with

benefit of hindsight.’’ We can still fall into this same old trap, though, if we don’t

fully utilize the tools at our disposal.

67

STOCHASTICS AND AVERAGES AND RSI! OH, MY!

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!