Factor investing has been around in portfolio management for some years. Based on algorithmic rules it became the big thing in trading and the ETF industry. But is there still some money to be made? Is small beta still smart or just beta? This article will give you a Tradesignal framework to test the factor investing ideas by your own. Continue reading

# Entry

# Technical vs. Quantitative Analysis

** “The stock market is never obvious. It is designed to fool most of the people, most of the time”** Jesse Livermore Continue reading

# An Algorithmic Stock Picking Portfolio

In this article I will discuss a simple algorithmic stock picking approach based on momentum and volatility. The goal will be to generate excess returns versus a capital weighted stock basket. Continue reading

# Bollingerband: The search for volatility

Usually it makes no sense to fight against normal distribution. But there are setups which have got a high probability of unexpected behaviour. Volatility can be the key to future market movements. Continue reading

# IV Percentile – when to sell volatility

Volatility trading: when to buy and when to sell volatility Continue reading

# Implied vs. Realized Volatility for NASDAQ100 stocks

*(1) You shall only trade when the chances are on your side* Continue reading

# Scanning for Support and Resistance Probabilities

I have been in search for a signal I could use for a short vertical spread or naked short option strategy. So my main concern has been **to find a level, which will most probably not be penetrated** over the next few bars.

This is what I came up with. Continue reading

# Statistics of VIX

The CBOE volatility index VIX measures the market’s expectation of future volatility. This article will show you some key statistics of VIX and help you to decide if it is better to buy or to sell volatility.

# Statistics of VIX

The spikes to the top and the long phases of relatively low volatility are reflected in a left-leaning distribution diagram and a long tail towards the higher levels. The median value is 17%, meaning 50% of the prices are above (below) this level.

The next chart shows the distribution of returns over 25 trading days. The median price movement being slightly shifted to the negative area shows the mean reverting characteristics of volatility.

## Buy or sell volatility?

Analysing the level of VIX and the returns afterwards yields an even more interesting picture:

The green line gives the 25 bar percentage returns of VIX, with VIX noting above 25, the red line gives the returns with VIX below 15. Observe the median of the two lines:

The median 25 bar return with VIX above 25 (green) is around -15%, only 20% of the returns are positive when VIX is currently above 25. Sell volatility.

The median returns with VIX currently below 15 (red) is above 0% and with a fat tail to positive returns. Buy volatility. (data from 2004-2018)

## Adverse movement of VIX

The above chart suggests that going short on volatility, if VIX is above 25, seems to be a good idea. But it is not without risk. The chart below shows what can go wrong during the next 25 days. The distribution diagram gives the maximum adverse movement of the VIX, with VIX currently trading above 25.

The green line, VIX currently above 25, shows a +10% median maximum up movement over the next 25 days. So do not expect a short vola position to be without risk. Some adverse movement has to be expected.

On the other side, the distribution of the maximum loss of the VIX during a 25 day period shows a median of below -20%. This represents the profit potential of a short volatility position.

## Conclusion of VIX statistics:

If you plan to short volatility wait until VIX is trading above 25. If you want to buy volatility, do so if VIX is trading below 15.

# Machine learning: kNN algorithm explained

I always thought that inspiration and experience are key factors in trading. But every time my chess computer beats me without any inspiration, just by brute force, I get my doubts. This article will be about a brute force approach in trading. The kNN algorithm.

### Rule based trading

Rule based trading – algorithmic trading, is just a name for a set of if..then rules which will define the machines trading decisions. e.g. if the market crosses below the 200 day line, then short 100 contracts. If the market rises by 2% then exit the position. Easy stuff like this… (for the beginning)

This article will be a short introduction to machine learning. I will use a classic algorithm of machine learning to let my computer find a prediction for tomorrows market move. In the meantime I’ll have a glass of wine with some friends and let the machine do the job; At least that’s the idea, but can it be that simple in real life trading?

### Unsupervised machine learning – kNN algorithm

The kNN algorithm is one of the most simple machine learning algorithms. Learning, in this case, is only a nice sounding label, in reality kNN is more of a classification algorithm.

This is how it woks:

The scatter chart above is a visualisation of a two dimensional kNN data set. For this article I used a classical indicators of technical analysis to do the prediction: a long-term and a short-term RSI indicator. The dots on the two dimensional scatter chart represent the historic RSI values at a given point of time.

Now have a look at the fat circled point. This point represents today’s value. It means, that today’s RSI1 has a value of 63, and RSI2 got a value of 70.

Additionally to the position on the chart the dots have got colours. A green dot means that the market moved up on the following day, a red dot shows a falling market on the day after.

We already know what has happened in history, so it is easy to colour the historic dots. But we do not know the colour of today’s dot, as it is not known where tomorrow’s market will end.

Based on the chart above, will it be a red or green dot? Will tomorrow be up or down? Should I go long or should I go short?

### kNN – k nearest neighbours

To do a prediction of tomorrow’s market move, the kNN algorithm uses the historic data shown on the scatter plot above and finds the k-nearest neighbours of today’s RSI values. As you can see, our current fat point is surrounded by red dots. This means, that every time the two RSI values have been in this area, the market fell on the day after. That’s why today’s data point is classified as red. Wish it would be that easy all the times…

Call it classification or prediction, the two dimensional kNN algorithm just has a look on what has happened in the past when the two indicators had a similar level. It then looks at the k nearest neighbours, sees their state and thus classifies today point.

### kNN as Tradesignal Equilla Code

In this article I would like to show you an implementation with the Tradesignal programming language Equilla.

To implement the algorithm in Tradesignal we first have to do the shown scatter plot. The algorithm stores the values in an array.

8/9 calculates the value of the fast and slow RSI indicators

12/13 looks what will happen on the day after (for the training data set)

16/17/18 stores everything in an array.

The next task to complete is to calculate the distances of today’s RSI point to all the historic points in the training data set.

23/27 calculates the euclidean distance of today’s point to all historic points, line 29 then creates a sorted list of all these distances to find the k nearest historic data points in the training data set.

Nearly done. The next step is just to find out what classification (colour) the nearest points have got and use this information to create a prediction for tomorrow. This is done in lines 33 to 35

Have a look at the scatter chart at the beginning. If this would be the data stored in our training data set, the prediction, using the 5 nearest neighbours, would be -5. All the 5 nearest neighbours of our current data point are red.

Now that we got a prediction for tomorrow, we need to make use of this prediction and trade it. The returns then will show if everything works as predicted.

Over here I just do a simple long/short interpretation of the prediction, but of course you could also use the quality of the prediction (+5 or +1?) in some sort of way. Position sizing…?

### kNN algorithm performance

The next chart shows 2000 bars of daily Brent data. It uses a 14 and 28 day RSI to predict the next day’s move in the Brent oil market. The training was on the first half of the data set, and the 5 nearest neighbours did the classification.

Underneath the chart the returns of this test are shown. (strategy equity). On the bottom of the char you see the two RSI indicators used for the generation of the prediction / buy-sell command.

### kNN algorithm – conclusion

The kNN algorithm offers a framework to test all kind of indicators easily to see if they have got any predictive value. Judging on the shown graph it seems to work. It seems to be possible to use these two RSI indicators to predict tomorrow’s Brent move.

But unfortunately this also could be just completely useless curve fitting. It is you who has to select the indicators and their periods and you will have to define if you like the outcome of a selected parameter set. To many degrees of freedom to be sure. The kNN algorithm is useful, but its application in finance has to be treated carefully. Otherwise bad surprises are guaranteed

Not everything can be done by brute force, inspiration and experience are key factors in finance…

# NASDAQ 100 long term candlestick scanner

## A short update on the long term Candlestick Scanner.

The Candlestick Scanner scans the Nasdaq 100 stocks for long term bullish or bearish reversal patterns.

The basic idea is to search for hammer and hanging man candlestick patterns. Usually these patterns work nicely on daily charts. My Candlestick Scanner searches for these two patterns on every time frame, from a 1 day per bar compression up to a 250 days per bar compression. This enables me to use a simple, well defined and documented pattern as a description of short to long term reversal setups.

But see for yourself which Nasdaq stocks seem to change the direction according to the long term Candlestick Scan. The list gives you the duration of the reversal formation (expect about the same time to either reach the target or get stopped out) The detected pattern becomes a valid entry signal if a new high (hammer) or low (hanging man) is established.

Bullish reversals on the left side, bearish reversals on the right side.