Quantitative Finance 101

The cutting edge of financial analysis these days uses many varied technical indicators to help analysts predict the future. Anything that can help analysts estimate what the future value of a stock will be can allow traders to take action now to gain an advantage in the market.

Some of the most-commonly used technical indicators are shown below, each with their own analysis widget. The data within each widget is controlled using the inputs below.

Select Stock
Select start date
Select end date

Moving Averages

For every point in our data, we can calculate averages of the previous N points. This helps us to gauge general trends over time, which may be able to help suggest future trends.

There are two main types of moving average - Simple Moving Average (SMA) and Exponential Moving Average (EMA). The SMA is simply just the numeric mean over the previous N points. Because of this, changes in the SMA trend always lag behind changes in the underlying data. The EMA is calculated by giving more weight to the more recent points, so the EMA trend follows the underlying data-trends more closely.

SMA Period: 14
EMA Period: 14

Note how the EMA (orange line) typically lies above the green line (SMA) when the stock's value is increasing, and vice-versa when the stock's value is decreasing. These cross-overs can be used as indicators of when to buy and sell stocks in order to make profits / reduce losses.

Under the current configuration, such a strategy would return % against the benchmark buy-and-hold returns of %.

Moving Average Convergence-Divergence

Moving Average Convergence-Divergence (MACD) is another very common indicator in quantitative finance. As discussed earlier, moving averages can help indicate periods when it is a good time to buy or sell. MACD takes this another step further.

Two EMAs are calculated with two different time periods - one short and and one longer (typical periods are 12 and 26 respectively). The difference between the two EMAs is calculated, and this is called the MACD. Typically, this MACD signal is then fed into another EMA to smooth out variation (typically with a period of 9). When this smoothed MACD signal is greater than 0, that is often considered to be a good time to buy a stock. Similarly, when the smoothed MACD signal is below 0, it is considered a good time to sell the stock. This MACD value is essentially a comparison of whether the shorter term trends are showing an increasing / decreasing trend relative to the stock's longer-term trends.

MACD short: 12
MACD long: 26
Signal: 9

Using times when the signal crosses a threshold value of 0 as indicators of when to buy / sell, the current configuration would return % against the benchmark buy-and-hold returns of %.

Relative Strength Index

The Relative Strength Index (RSI) is an indicator which estimates whether a given stock is over-sold or over-bought. If there has been a buying frenzy on a given stock, chances are that it will soon fall. Similarly, if there has been a selling frenzy, it is likely that the stock will soon rise.

The RSI indicator tries to capture this behaviour, and creates a normalised score between 0-100 to indicate how likely the recent trend is to continue. Typically, an RSI of 70 indicates that a stock is over-bought and may soon begin to fall, and an RSI score of 30 indicates that a stock is over-sold and may soon rise. Therefore, when a stock crosses these threshold values, it may be a good time to buy or sell, depending on your current position.

RSI Period: 14
RSI Sell: 70
RSI Buy: 30

It's a little trickier to calculate returns for an RSI-based strategy as it typically won't stay over-sold / over-bought for very long, but let's give it a go.

Initially, we assume we hold some stock. If it crosses a threshold high value, we will sell the stock until the RSI drops below that threshold. If it crosses a threshold low value, we will double down on our position and buy more stock, which we sell once the RSI crosses back over the threshold.

With this strategy, the current configuration would return % against the benchmark buy-and-hold returns of %.

Bollinger Bands

Bollinger Bands are hypothetical boundaries of a stock based on its recent values and the variation in these values. Using a simple moving average and calculating the standard-deviation as well, we can get a feel for typical movements in this stock. If we then see the stock's value move outside of these theoretical boundaries, it usually means that the movement will revert and end up back inside the boundaries.

Most analysis just considers Bollinger Bands with a fixed "N" value (usually 2). Then, if the stock moves outside of this band, action would be taken. However, I feel that calculating the ratio is more informative than a simple "inside" / "outside" indicator. It can also show progression of trends over time, which a binary indicator cannot. Therefore, I usually work with what I have dubbed the "Bollinger Ratio", which is simply (stock value - rolling mean) / (rolling standard deviation). It's essentially a rolling z-score.

BB Period: 20
BB Sell: 2
BB Buy: -2

Similar to the RSI strategy, let's assume that we initially hold some stock and if the rolling ratio exceeds a threshold high value, then we sell because we expect the stock to drop in value soon. Similarly, if the rolling ratio drops below a threshold low value, then we will double our position because we expect it to increase in value soon.

With this strategy, the current configuration would return % against the benchmark buy-and-hold returns of %.

Conclusion

This blog has presented four of the most common technical indicators in use today. Hopefully, it can be seen that these indicators have the potential to improve stock market returns, if used properly. In reality, traders will use a combination of many indicators to inform themselves, and then use their judgement. There is a huge amount of information available that can inform an investment decision that cannot be captured in a simple open / high / low / close dataset.

These indicators are also a common starting place for algorithmic trading, where computers decide by themselves whether or not to invest their owners' money in a stock. It's difficult to predict which direction a given stock will go at the best of times, even with years of experience, but these indicators are simple for computers to calculate and can help them decide which stocks offer the best potential. Algorithmic trading can get insanely complicated. When I get some of my algorithms humming along nicely, I'm sure I'll do another blog on that topic.

Hopefully you have enjoyed this demo! I certainly enjoyed making it. If there is anything else on this topic you would like to see, please feel free to drop me a line at c.turner.software@gmail.com.

Rate this page?

Love
Like
Meh
Dislike
Awful

Comments

No comments yet. Want to be the first?