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 marketPosition =-1 then

If c < entryPrice - 3* avgTrueRange(10) then buyToCover

this bar on close

if c > entryPrice + 1* avgTrueRange(10) then buyToCover

this bar on close

50

STOCHASTICS AND AVERAGES AND RSI! OH, MY!

The description of this algorithm looks very similar to the RSI and stochastic

overbought/oversold, but there is one esoteric difference. Notice how the entries

are initiated. Long entries require the CCI to cross above −100, meaning that the

CCI has been in the oversold territory for at least one bar. Just the opposite is true

for short entries; CCI must cross below +100. This is different from the other

algorithms in that entries are delayed until the indicator starts moving in the same

direction as the desired market direction. This delay is a double-edged sword in that

you might get confirmation of market direction but at the cost of worse price.

Many of today’s trading and testing platforms have the keywords CROSS ABOVE

and CROSS BELOW built into the programming language. These keywords are

simple shortcuts meant to make programming easier to understand and implement.

Using the CCI indicator as an example, here are the equivalent computer codes to

the keywords:

CROSS ABOVE −100 : CCI[1] < −100 and CCI[0] > −100

CROSS BELOW +100 : CCI[1] > +100 and CCI[0] < +100

Remember the values inside the square brackets indicate the number of bars/days in

the past. In later chapters, where different platforms are discussed, you will see these

keywords. Figure 2.10 shows some trades generated by this first CCI algorithm.

Since the flowchart for this algorithm is so similar to the RSI and stochastic, it will

not be shown for brevity’s sake. However, the all-important performance metrics

are shown in Table 2.5.

FIGURE 2.10 Trades generated by the CCI algorithm when it crosses above 100 and below −100.

Source: TradeStation

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!