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.

The manner in which we developed the MACD algorithm does not care about

absolute prices because it looks at the difference between the moving averages as

either positive or negative; it does not care about the magnitude of difference.

■ Price-Based Indicators

Price-based indicators reflect trend and volatility. As we stated earlier, applying a

moving average to an instrument’s historical data will smooth out the data and soften

wild market swings. In other words, a moving average eliminates a good portion of

the noise associated with daily price changes.

58

STOCHASTICS AND AVERAGES AND RSI! OH, MY!

Simple, Exponential, and Weighted Moving Averages

The most often used moving average is the simple version. Here, you sum up

the closing prices over the past N days and then divide by N. The exponential

moving average calculation uses a smoothing factor to place a higher weight on

recent data points and is regarded as much more efficient than the linear weighted

average. Having an understanding of the calculations is not generally required

for most traders because most charting packages do the calculation for you. But if

you are interested in the calculations, here are the steps involved in calculating the

exponential and weighted moving averages:

1. Seed the exponential average initially with a simple moving average.

2. Calculate the smoothing factor: multiplier = 2 / (EMA length + 1).

3. EMA[0] = (close[0] − EMA[1]) * multiplier + EMA[1].

The key to the EMA calculation is the smoothing factor multiplier. If we were

calculating a 20-day EMA, the multiplier would be equal to 2 / 21, or 0.0952. In

this example, a weighting of nearly 10 percent is applied to the most recent data

point. A weighted moving average is slightly more complicated to calculate. Sticking

with 20 periods, here are the steps involved in the calculation:

1. Sum up the values of the length of moving average : 20 + 19 + 18 + 17 +16

+15 + 14 + 13 + 12 + 11 + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 +1 = 210.

2. Multiply the oldest price by 1 /20 and second oldest by 2/20 and third oldest by

3/20 and so on.

3. Sum up the products and you will have a weighted moving average. As you can

see, the most recent data is weighted the most.

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!