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 behavior.  Volatility can be the key to future market movements.

Bollinger bands width percentile

Bollinger Bands are a great tool to describe market volatility. And my favorite tool to measure the width of Bollinger Bands is Bollinger percentile.

Like the IV percentile indicator my Bollinger percentile indicator is a probabilistic indicator. It gives the probability of Bollinger Bands having a narrower upper band – lower band range than currently given.

A Bollinger percentile of 93% (screenshot) means, that in only 7% of the last 1000 trading days Bollinger bands have been wider than they are today.

A Volatility Prognosis

We already had some statistics on how likely the market will be within today’s Bollinger band in a given number of days from now.

This time I would like to find out if the market will be within a market neutral volatility prognosis cone in a given number of days from now.

Bollinger bands are somehow trend following. This comes due to the moving average they are based on. The volatility cone I am testing in this article is market neutral. It has no bullish or bearish offset. I am using Kahler`s volatility to calculate this fair bet vola cone.

Questions:

  1. How likely is the market within the shown volatility cone within 20 days from now?
  2. Can Bollinger Percentile identify areas with a higher/lower probability of being inside/outside of the vola cone?

Outside Kahler`s volatility cone in 20 days from now

First let’s run a test on the probability of the market to be outside the shown fair bet vola cone within 20 daily bars from now.

Running on 10 years of daily data the test shows the expected result; In slightly more than 50% of time the stocks have been outside of the fair bet vola cone.

Bollinger percentile volatility prognosis

Old market wisdom says that after a volatile phase things will calm down. This is the basic idea behind the next tests.

I would like to see if the probability of being in or out of the projected vola cone can be determined by looking at the width of the current Bollinger band.

Running the same test as above, but calculating the results depending on the level of the Bollinger percentile indicator gives a new picture.

If Bollinger percentile is above 50, you got a higher probability of being outside the volatility prognosis in 20 days from now than you would have with a Bollinger percentile below 50. Bollinger percentile above 50 means, that the width of the Bollinger band has been below the current level in more than 50% of the last 250 bars.

The width of the volatility cone itself is not influenced by the width of the current Bollinger band. It’s width is calculated over  the last 1000 daily bars of historic data and does not change a lot over time. The Bollinger band is calculated over 20 days.

On the screenshot above you see the probability of the market of being outside the volatility cone in 20 days from now. The first row of results gives the probability of being outside if Bollinger percentile is above 75%, the second row gives the results for being outside the vola cone when Bollinger percentile is below 25%. As you can see, there is quite a difference.

The results behave opposite to what I would have expected.

A wide Bollinger band does not lead to a higher probability of the market being inside a market neutral vola prognosis. I would have assumed, that if we got a wide Bollinger band, the market would calm down and stay within a range for some days. But the opposite is true.

Takeaways

Depending on your trading style these findings can be used is several ways.

  • If you trade market neutral strategies, the vola projection gives the break even points of a fair priced at the money straddle, you can use these findings to decide if it is better to buy or sell a straddle.
  • If you are trading directional you can use these findings to look for probable breakout scenarios or for placing target/stop orders to make use/protect form unlikely events.

Research pays off, contact me for more details.

 

If you like it please link it

Tradesignal Implied Volatility and IV Percentile Scanner

Implied Volatility and IV Percentile

Thanks to https://www.optionstrategist.com/calculators/free-volatility-data  implied volatility and IV percentile data is available. For free on a weekly basis. Using this data and the given code the data can be loaded into Tradesignal. This enables you to do your custom market scans, combining Tradesignal technical analysis and the implied volatility data from the optionstrategist website.

Free data

The first step to use the optionstrategist data would be to safe it into a text file. Just copy and paste the data, no additional formatting is required. The free data on the website is updated every Saturday.

Read the file in Tradesignal

After storing the data in the text file, you will have to open a scanner in Tradesignal and apply the given code. Set the scanner to load at least 250 data, as the long history is used to calculate the realized volatility.

Scanner code (indicator)

function code for kvol:

The code is build to run with the version 9 of Tradesignal online terminal

It will read the implied volatility and the IV percentile from the stored file. Additionally it will calculate the fair price for a straddle (realized vola) and compare implied volatility to the fair price volatility.

Scanning for promising stocks

I ran a scan on the S&P500 stocks, and to reduce the list of possible trades I applied some filters to the 500 results.

This reduced the 500 S&P stocks to a handful stocks. They all are traded with sufficient volume, have got a high IV percentile, the implied volatility is way higher than the fair price vola would be and they are all in a price range that fits my portfolio size.

Feel free to define your own scans. With this Tradesignal code and the given free data containing all US stocks it should be easy to find the right candidate for your next trade.

 

If you like it please link it

IV Percentile – when to sell volatility

You got to know when to hold ’em,
Know when to fold ’em,
Know when to walk away,
And know when to run.
(Kenny Rogers)

When to sell implied volatility

Volatility is a nicely reverting time series. If it is high chances are good that it will come down again. The only problem is to find out when volatility is high, and when it is low. Unfortunately there are no absolute levels, you can’t say that 50% implied volatility is high, as this specific stock might have an implied volatility of 80% most of the time. So you can only compare the current volatility level to historic levels and so define if volatility is currently high or low.

Volatility rank

One simple measure to find out if volatility is high or low would be the volatility rank. It is calculated like the stochastic indicator used in technical analysis. Volatility rank (in %) = (current IV – Min IV)/(Max IV -Min IV). The maximum and minimum of volatility is usually calculated over one year.

But this calculation method has got some major drawdowns. Singular implied volatility spikes will affect the values of the year after, and it will seem that volatility is low, just because it is low relative to this one spike, but not in a broader sense. Also the absolute level has not meaning by itself. 50% would just mean that current IV is 50% of the last spike up.

IV Percentile – a probability based indicator

Unless IV rank, the stochastic like indicator, IV percentile is a probabilistic indicator. It does not give the position of current implied volatility relative to it’s historic levels, it give the probability of IV for being lower than today. So a IV percentile reading of 0 (zero) means, that there has been no IV lower than the current one. This would be a nice setup for buying volatility. It most probably will go up. On the other side, a volatility reading of 93% (as we have it on October 12th after the S&P sell-off means, that on 93% of all days in history volatility has been lower than the current one. You might want to go with the probabilities and sell volatility.

IV percentile does not only give you a level, it also gives you the probability of falling volatility.As soon as IV percentile is above 50 you have a better than 50% chance that volatility will be lower soon. Have a look at the VIX article I did, it comes to a similar conclusion. This is a key indicator when you plan to sell implied volatility.

Scan for IV Percentile

IV percentile is the perfect indicator for a market scan. Find all stocks with an IV percentile above 50 (look for 85% and higher…) and you will have an edge when selling volatility. As you can see on the chart above, a high IV percentile number also correlates with an implied volatility being above the fair bet volatility. So your edge actually has two legs: (1) current IF is high and will most probably revert down (IV percentile > 50%) and (2) implied volatility is overpriced according to historic measures.

If you add all the edges you can get the luck will be on your side.

Free IV percentile data is available at https://www.optionstrategist.com/calculators/free-volatility-data

 

If you like it please link it

The Hindenburg Omen – Stock Market Crash Ahead?

The Hindenburg Omen is an indicator which is believed to forecast market crashes. Unfortunately it does not work, but the idea behind this indicator is worth to be discussed.

Market Breadth – Hindenburg Omen

The Hindenburg Omen is a market breadth indicator. It describes how correlated stocks are within a market behave.

I already had a market breadth indicator in this blog a long time ago, the percentage of stocks within a market above the 200 day average. The Hindenburg Omen does not use moving averages, it is based on the number of new highs and lows in the market.

Hindenburg Omen: idea and calculation

To get a warning signal for an upcoming stock market crash the Hindenburg Omen indicator observes the number of stocks making new 54 week highs and the number of stocks making 54 week lows. In a strong bull market you will usually see a lot of new highs but hardly any new lows, in a bear market you will see new lows, but no new highs.

The ingenious idea behind the Hindenburg Omen indicator is, that a bull market will disintegrate before it is over. This means, that not all stocks will rise with the general tide, some will already start to fall while some others are still rising. So to get a warning signal that the current bull market is over (and a crash might come), you will have to see some stocks with new highs and some stocks with new 54 week lows.

Originally the indicator has been calculated on all stocks on the NYSE. And the original writings suggest that at one given time at least 2.8% of all stocks make new highs and 2.8% of all stocks make new lows. Up to 3 additional rules have been formulated to make it a valid warning sign, but this most probably is just curve fitting to historic events and would not work in the future. But the original idea of a market with new highs and new lows at the same time is worth remembering.

The Hindenburg Omen Indicator

The chart above gives my interpretation of the Hindenburg Omen Indicator for the Tradesignal software suite. It consists of 3 lines:

The red line shows the percentage of stocks within the chosen market which make new 54 week (adjustable) lows. The green line gives the percentage of stocks which make new 54 week highs. The blue histogram gives the actual Hindenburg Omen signal. It starts rising as soon as there are a specific percentage (cut off) of stocks making new highs and other stocks making new lows. As you can see on the left side of the chart (Dow Jones 30 stocks) there has been a strong signal before the 2008 and 2015 correction. On the right side of the chart the Hindenburg Omen indicator is applied to the 500 S&P stocks.  Notice the many signals in 2017. These have been a sign of an overheating market, as some stocks already made new lows, although the heavy weighted stocks still drove the market to higher areas.

 

If you like it please link it

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.

Algorithmic RSI Support and Resistance Levels

We are all familiar with oscillators like the RSI indicator. It gives an idea if the market is oversold or overbought.

The chart gives a basic idea of the signal I am looking for. Once the indicator is leaving the overbought / oversold area, there should be a good chance that the market actually stays above or below it’s previous high or low. If this probability is high enough, it would be a great signal for a short vertical spread or to sell a naked put / call option. (be aware of the unlimited risk in the naked short trade!) Both strategies win, if the selected level is not penetrated at expiry.

What is manually drawn on the chart above can also be done automatically. The following chart shows how it looks like if you use the code given at the end of the article.

Every time the RSI leaves the extreme zones the indicator will draw the previous high or low for a given prognosis interval. To enhance the chances and not to get too many signals in a trending market I also made use use of the ADX indicator. So to see a signal on the chart, RSI has to leave the extreme level while ADX signals a sideway market. This should give the best signal quality.

The three signals shown would have resulted in a winning trade as the market did not cross the shown support / Resistance levels. But how does it work out in the long term?

Continue reading

If you like it please link it

Backtesting Market Volatility

If you want to predict volatility, you can place a bet on the option market. Just buy an at the money put and call, and at expiry day you will either win or lose, depending on the actual market move since you bought the straddle and the price you paid for the straddle. To put it simple, if the market moves more than you paid for the two options you will win, otherwise you will lose. This article is about a back test of volatility.

The fair price for volatility

When I look at the S&P500 I could buy or short a straddle with 16 business days until expiry right now for around 70$. That’s the implied volatility.

When I look at the standard deviation of 16 day returns, using the last 30 days to calculate it, it shows me a volatility of around 30$. That’s historical volatility.

When I use my own fair bet KVOL Volatility, it gives me a volatility of about 50$

Now I got three measures for volatility, but which one is the best prediction for future market volatility? And how big will the error (=wins and losses) be if we place this bet over and over again?

Backtesting volatility

Placing an perpetual bet on future volatility using the payback profile of a short straddle will give me an idea on how good historical volatility and Kahler’s volatility was able to predict future volatility. In a perfect world this virtual test strategy should be zero sum game; if not, future volatility is either over or underestimated by these 2 indicators.

If I know which indicator gives me the best volatility assumption, I can use this information to find out, if the current implied volatility of the market is too high or too low. Sell high, buy low…

The chart above gives you an idea on how I did the backtest. I place a weekly bet on volatility, based on a short straddle trade. So if I close outside the of the projected volatility, I have a loss. If the market closes inside the projection, I win. The maximum win will be the price of the volatility indicator at the beginning of the bet, the max loss is the point move within the week minus the price I got for volatility at the beginning of the bet.

Continue reading

If you like it please link it

Demystifying the 200 day average

The 200 day average is usually considered as a key indicator to tell if markets are bullish or bearish. But can this be proved statistically, or is it just an urban legend handed down from one generation to the next?

Let’s do some studies and find out.

The 200 day moving average

Looking at the chart of the S&P500 index and it’s 200 day average let’s me think that the 200 day average is actually a useful indicator to separate the bull and bear phases of the market. But the eye tends to see what the brain is looking for, so you might have focused on the crash 2008 and the bull market afterwards, but have ignored all these little breaches below the 200 day moving average which happened in between. As a trader I can`t make any money with knowing that there has been a long period under the 200 day average, i need to make my decision as soon as the market drops below the 200 day average.

Distribution of returns above and below the 200 day moving average

The chart above (on the right side) shows the returns distribution of 10 day returns. The green distribution represents the 10 day returns if S&P500 is trading above it`s 200 day moving average, the red line represents the 10 day returns returns when the market is trading below its 200 day moving average. Data from 1980 up to now has been used.

What are the curves telling us?

Continue reading

If you like it please link it

Money for nothing

We already had a post regarding the mean reverting tendency of Volatility, now it`s time to make some money using this information.

Trading Volatility

The VIX volatility index on the chart above looks like an easy to trade instrument, just buy when it is around 10 and sell when it has doubled, tripled, quadrupled…

But unfortunately life is not that easy, VIX is just an index and you will not be able to buy or sell it. You might try to trade volatility using options, but there is a better plan to make money on this wonderful asset class, the VXX, BRCL BK IPTH S&P 500 VIX SH FTRS ETN.

Continue reading

If you like it please link it

Machine Learning – KNN using Tradesignal Equilla

I always thought that inspiration and experience is a key factor in trading. But everytime my chess computer beats me without any inspiration, just by brute force, I start to reconsider this assumption. This article will be about a brute force approach in trading.

Rule based trading

I have never been a great believer in classical technical analysis. If you ask 2 analysts about the current trend in the market, you get at least 3 answers. So I turned to algorithmic trading, using the tools of technical analysis in a new way, doing if..then conditions, backtesting them, refining the rules and parameters until the desired result was shown. These if..then based conditions, like if the market is above it`s 200 day line then go long, are mostly found by experience and inspiration. Isn’t my brain just a neural network which can be trained with historic data (experience), enhanced with a glass of wine for the inspiration?

Today I would like to take a voyage into machine learning. I would like to let my computer find the rules by itself, and just decide if I like the results or not. I’ll have the glass of wine with some friends and let the machine do the job; This sounds tempting to me, but can life really be as easy?

Unsupervised machine learning – kNN algorithm

The knn algorithm is one of the most simple machine learning algorithms. Learning might be the wrong label, in reality it is more of a classification algorithm. But first let’s see how it works.

The scatter chart above is a visualization of a two dimensional kNN data set. For this article I used a long term and a short term RSI. The dots represent the historic RSI values. Have a look at the fat circled point. It just means, that todays RSI1 has a value of 63, and RSI2 got a value of 70. Additionally the dots have got colours. A green dot means the market moved up on the following day, a red dot shows a falling market on the day after.

kNN – k nearest neighbours

To do a prediction of tomorrow’s market move, the kNN algorithm has a look at the historic data (shown on the scatter plot) 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 2 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. Call it classification or prediction, the kNN algorithm just has a look on what has happened in the past when the RSI indicators had a similar level. Have a look at this video, it is a great explanation on how the algorithm works.

kNN as Tradesignal Equilla Code

Computer kiddies would implement this algorithm in Python or R, but I would like to show you an implementation with the Tradesignal programming language Equilla. It is way faster than Python, and has got the advantage that I can directly see all the advantages and disadvantages on the chart. It is not just number crunching.

To implement the algorithm in Tradesignal we first have to do the shown scatter plot, but not graphically but store the 2 rsi values and the next days market move(colour of dots) into an array.

In line 8&9 the rsi values are calculated, line 12&13 calculates the next day`s market move. Line 15 to 20 then stores the data into the training data array. This is done for the first half of the data set, for my example I will use the data from bar 50 to 1000 on my chart of 2000 data points.

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.

Line 23 to 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.

We are 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 just have to trade it:

kNN algorithm performance

Lets have a look if this simple machine learning algorithm works. Using 2000 days of backward adjusted brent data, I used a 14 and 28 day RSI to predict the next day move. The training was done on bar 50 to 1000, and I used the 5 nearest neighbours for the classification.

Knn algorithm – conclusion

Judging on the shown graph it seems to work. It seems to be possible to use these 2 RSI indicators to predict tomorrow’s brent move.

kNN algorithm gives me a framework to test all kind of indicators or even different data sets easily and see if they have got any predictive value.

This is definitely an addition to classical algorithmic trading, using if..then conditions build from experience and intuition.

But you might still need some intuition to find the right data sets, indicators and parameters to get a useful prediction. Not everything can be done by machine learning…

 

 

 

If you like it please link it

Using Autocorrelation for phase detection

Autocorrelation is the correlation of the market with a delayed copy of itself. Usually calculated for a one day time-shift, it is a valuable indicator of the trendiness of the market.

If today is up and tomorrow is also up this would constitute a positive autocorrelation. If tomorrows market move is always in the opposite of today’s direction, the autocorrelation would be negative.

Autocorrelation and trendiness of markets

If autocorrelation is high it just means that yesterdays market direction is basically today’s market direction. And if the market has got the same direction every day we can call it a trend. The opposite would be true in a sideway market. Without an existing trend today’s direction will most probably not be tomorrows direction, thus we can speak about a sideway market.

Autocorrelation in German Power

But best to have a look at a chart. It shows a backward adjusted daily time series of German Power.

The indicator shows the close to close autocorrelation coefficient, calculated over 250 days. You will notice that it is always fluctuating around the zero line, never reaching +1 or -1, but let`s see if we can design a profitable trading strategy even with this little bit of autocorrelation.

The direction of autocorrelation

Waiting for an autocorrelation of +1 would be useless. There will never be the perfect trend in real world data. My working hypothesis is, that a rising autocorrelation means that the market is getting trendy, thus a rising autocorrelation would be the perfect environment for a trend following strategy. But first we have to define the direction of the autocorrelation:

To define the direction of the autocorrelation I am using my digital stochastic indicator, calculated over half of the period I calculated the autocorrelation. Digital stochastic has the big advantage that it is a quite smooth indicator without a lot of lag, thus making it easy to define its direction. The definition of a trending environment would just be: Trending market if digital stochastic is above it`s yesterdays value.

Putting autocorrelation phase detection to a test

The most simple trend following strategy I can think about is a moving average crossover strategy. It never works in reality, simply as markets are not trending all the time. But combined with the autocorrelation phase detection, it might have an edge.

Wooha! That`s pretty cool for such a simple strategy. It is trading (long/short) if the market is trending, but does nothing if the market is in a sideway phase. Exactly what I like when using a trend following strategy.

To compare it with the original moving average crossover strategy, the one without the autocorrelation phase detection, you will see the advantage of the autocorrelation phase filter immediately: The equity line is way more volatile than the filtered one and you got lots of drawdowns when the market is sideways.

Stability of parameters

German power has been a quite trendy market over the last years, that`s why even the unfiltered version of this simple trend following strategy shows a positive result, but let`s have a test on the period of the moving average.

Therefore I calculated the return on account of both strategies, the unfiltered and the autocorrelation filtered, for moving average lengths from 3 to 75 days.

Return on account (ROA) =100 if your max drawdown is as big as your return.

The left chart shows the autocorrelation filtered ROA, the right side the straight ahead moving average crossover strategy. You don`t have to be a genius to see the advantage of the autocorrelation filter. Whatever length of moving average you select, you will get a positive result. This stability of parameters can not be seen with the unfiltered strategy.

Autocorrelation conclusion:

Trend following strategies are easy to trade, but only make sense when the market is trending. As shown with the tests above, autocorrelation seems to be a nice way to find out if the market is in the right phase to apply a trend following strategy.

 

If you like it please link it