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 close crosses below myBotBand, then

SellShort MOC

If position is long, then

If close crosses below myAvg, then

Sell MOC

If position is short, then

If close crosses above myAvg, then

BuyToCover MOC

64

STOCHASTICS AND AVERAGES AND RSI! OH, MY!

The beauty of this algorithm is in its simplicity; we don’t even need to sketch

a flowchart. There is another facet of this algorithm that makes it a winner—it’s

self-adaptive. Meaning the bands are moving (adapting) around the average based on

an intrinsic property of the underlying instrument. And that property is volatility.

Volatility reveals one of the most important things we need to know about an

instrument, and that is risk. Risk is directly proportional to volatility—the larger

the swings, the riskier the market. I am jumping the gun here, but we will use this

risk measure as a filter in version 2 of the Bollinger Band trend algorithm. Volatility

also informs us of market noise. When the Bollinger Bands expand during high

levels of volatility, they are indicating a chaotic situation—a situation where entry

criteria should be made more difficult to trigger. The following is the pseudocode

for version 1 of the trading algorithm:

‘Trend Following with Bollinger Bands

‘Utilizing 60-day average and 2 standard deviations

‘Version 1

myAVG = SMA(C,60)

myTopBand = BollingerBand(C,60,+2)

myBotBand = BollingerBand(C,60,-2)

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

Table 2.8 shows the individual results of Bollinger Band version 1 across 35

futures markets.

In the prior paragraphs, I hinted of a version 2 of this algorithm utilizing the

volatility as trading filter. Risk aversion is most often the number-one consideration

in the development of a trading algorithm, and we can use the volatility as a

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!