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 and close > entryprice +

1* avgTrueRange(10) then

BuyToCover this bar on close

If marketPosition =-1 and close < entryPrice -

3* avgTrueRange(10) then

BuyToCover this bar on close;

Figure 2.7 illustrates the model of the RSI failure swing algorithm. As you can

see from the diagram, this isn’t a flowchart. It’s our old friend the FSM, so let’s

move through the different states of the machine. We start off gobbling one bar at a

time until we come across a RSI pivot high with a value of 70 or greater. Once this

occurs, the machine goes into State 1 and starts gobbling more bars. The machine

can only transition out of State 1 if one of three events occur: an occurrence of a

RSI pivot low, an RSI value > the original RSI pivot high value, or an RSI value that

is less than 30. Only an occurrence of an RSI pivot low can propel the machine to

State 2. The other two conditions will reverse the machine to the Start state. Once

in State 2, the machine looks for yet another RSI pivot high. In addition to a new

pivot high, another condition must be met before moving onto State 3, and that is

the RSI pivot high must be less than the original RSI pivot high. The same conditions

that reset the machine to the Start state exist at State 2. After the machine attains

State 3, it then tries to propel itself to State 4 by finding an RSI value less than the

RSI pivot low found in State 1. If this occurs, an order to sell short the market is

placed on an MOC basis. Again, the exact same criteria for reversing the machine

back to the Start state are in force in State 3.

RSI < 30

RSI Pivot Hi > 70 State 1 RSI Pivot Lo State 2

Start

RSI > RSI Pivot

Hi

RSI > RSI Pivot

Hi

RSI > RSI Pivot

Hi

RSI Pivot Hi < Prior Pivot Hi

State 3

41

STOCHASTICS AND AVERAGES AND RSI! OH, MY!

FSM

Modeling RSI Swing

Failure Algorithm

Accept

Place

SellShort

Order

RSI < RSI Pivot Lo

FIGURE 2.7

Example of FSM modeling RSI Swing Failure.

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!