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.

If close crosses above myTopChannel, then

Buy MOC

If close crosses below myBotChannel, 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

Here is the pseudocode for the algorithm:

‘Trend Following with Keltner Channels

‘Utilizing Typical Price = (H + L + C)/3

‘Utilizing 60-day average and 2 average true ranges

70

myAVG = SMA(C,60)

myTypicalPrice = (H + L + C)/3

myTopChannel = KeltnerChan(myTypicalPrice,60,+2)

myBotChannel = KeltnerChan(myTypicalPrice,60,-2)

STOCHASTICS AND AVERAGES AND RSI! OH, MY!

If close > myTopChannel then

Buy this bar on close

If close < myBotChannel 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

Using the ATR instead of standard deviation creates smoother outer Bands due to

how ATR reacts slower than deviation. Figure 2.15 shows a chart with both Keltner

Channels (60 length and 2 ATR) and Bollinger Bands (60 length and 2 STDDEV)

applied to the underlying data.

Notice how much smoother the Keltner Channels are compared to the Bollinger

Bands. Does this mean they are better? Since the TP takes into consideration more

data, is it a better gauge than just the close? Looking at the chart it seems like

both indicators got into the short crude position at about the same time. This is a

difficult question so let’s use the computer tell us which is the better algorithm.

This is not going to be an easy task because it is difficult to equate standard deviation

to ATR. As you can tell by the chart, the Bollinger Bands encompass the Keltner

Channels a majority of the time. This is a consequence of using the same settings

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!