The markets will go up and down, and usually it’s not my business why they do it, I am just interested in making my luck with a position on the right side of the trade. Continue reading
If you want to trade 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. Continue reading
The 200 day average is considered as a key indicator in everyday technical analysis. It tells us if markets are bullish or bearish. But can this claim be proved statistically, or is it just an urban legend handed down from one generation of technical analysts to the next? Let’s find out and demystify the 200 day moving average. Continue reading
Sometimes my data provider has not got the data I am looking for. Searching for downloadable csv data I recently came across google spreadsheets. It provides an easy way to get historical stock price data. Save it as csv and use it with your Tradesignal. Continue reading
If a bitchy prime minister and a crazy president weren’t enough, for the upcoming months the seasonal chart is also indicating further price setbacks. Continue reading
How to calculate volatility based on the expected return of a straddle strategy has been shown in part 1 of fair bet volatility KVOL.
Using and Displaying K-Volatility:
KVOL uses the given amount of historic returns to calculate an expected value of an at the money put and call option. The sum of these prices are the historic fair value for implied volatility. It can be used to compare current market implied volatility to historic fair values.
Beside calculating KVOL for a specific return period it can also be used to show it as a projection indicator on the chart.
The example on the chart gives such an expectation channel for the s&P500 at the beginning of each month. The 250 days before are used to calculate KVOL. The line underneath the chart is running KVOL for 13 trading days.
to win, with higher volatility expected: you would have bought a straddle at the beginning of the month, expiring at the end of the month. You should not have paid more than a KVOL for 25 bars (working days to expiry) would have suggested. You win if the chart is outside of the projection at the end of the month.
The shown example uses the 250 daily bars before the beginning of the month to calculate the returns and the price of KVOL. The projected lines represent the winning boundaries of the straddle at expiry.
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.
Volatility is a measure of risk. It describes how far a commodity will most probably move within a given period of time. The most common measure for volatility is historical volatility. But I do not like the complicated formula for standard deviation.
There has to be a better way to explain and calculate volatility….
The options market has got a perfect measure for volatility. Done without formulas, just by demand and supply. And as I believe in efficient markets, the option markets fair price for volatility will be my starting point.
To get the price for volatility at the option market you just have to place a bet. Assume you want to know the (expected) volatility for the next 30 days, then you would just add the price for an at the money put and call with 30 days to expiry. Option traders call this bet a straddle, and you would win if the market moves more than the price you have payed for the (european style) put and call.
The fair price for a volatility bet
Implied volatility and this Straddle bet is the starting point to calculate my own volatility measure.
The fair price for this bet is, when neither the buyer nor the seller of the bet has got an advantage. In the long run it should be a zero sum game game for both of them. Calculating the fair bet price for a straddle is the idea behind my volatility measure.
Think about a simple coin flip game. If you bet on head you can either win 1€ if head is up or nothing if tail comes on top. What would be the fair price for such a bet?
As head and tail got the same probability, the expected return of a bet on head’s up would be 0.5€. If I would sell you a bet on the next coin flip, I would charge you this 0.5€ to make it a fair bet. So you would either lose the 0.5€ if tail’s up, or win 1€ -0.5€ if head’s up. In the long run this would be a zero sum game for both of us. Do the same thing for the tail is up bet. It also got a value of 0.5€.
Historical Volatility vs. Kahler’s Volatility:
Historical volatility uses standard deviation of daily log returns to describe the volatility of the market. The standard deviation of this +1 -1 coin flip experiment would be 1€. The same would be true if you would buy a head’s up and a tail’s up bet; it would also cost you 1€. So for this simple example the fair bet based volatility is the same as the historical volatility.
But the market is not a coin flip. There will be some differences between historical volatility and KVOL fair bet based volatility.
KVOL vs. historical volatility:
The chart shows you a comparison between KVOL (blue) and historical volatility (standard deviation). On the chart shown above both calculate the volatility for 10 day returns, using the previous 30 bars as data sample.
As you can see historical volatility and KVOL are highly correlated.
But there are some major differences:
As an example in the end of 2017/beginning of 2018 KVOL starts to rise as the market is exploding to the upside. This is due to the virtual call used to calculate KVOL gains value. At the same time historical volatility stays low, as the market has got one direction and no setbacks.
Another advantage of KVOL is it`s response to singular events. As you can see on Sept. 3rd on the chart above the singular big red candle leads to a spike in historical volatility. It also raises KVOL, but not as much. As both indicators are calculated over the same period of bars they both got the same speed of change, but when you have a look at the scale you will see the advantage of KVOL: Historical volatility jumps from 0.2 to over 0.5 – it more than doubles just because of a single event. KVOL also raises,but only from 0.2 to 0.3.
For me this mild response to to singular events is the main advantage. Imagine a portfolio based on value at risk – would it really be useful to half the exposure just because historical volatility jumps after a single red candle?
KVOL – Tradesignal Equilla Code:
The code to calculate KVOL is simple and straightforward.
multi: just a multiplier, like you can display 1 or 2 standard deviations..
datapoints: The number of bars used to calculate KVOL
returnperiod: calculate the volatility for 1,2,3… bars
showresult: show the result as a percentage of the underlying or as an absolute number
show: show either kvol or the rank of kvol within the last 100 bars. This gives an idea if volatility is high or low
Meta: subchart(true); Inputs: multi(1.0), Datapoints(30), returnperiod(5), showresult(percent, absolute), show(result,rank); Variables:Kvol, i, rp,rc, rpsum, rcsum, call, put, hh,ll; rpsum=0; rcsum=0; for i =0 to datapoints-1 begin // loop over last bars rc=maxlist((close[i]-close[i+returnperiod])/close[i+returnperiod],0); // % return of call rp=maxlist((close[i+returnperiod]-close[i])/close[i+returnperiod],0); // % return of put rcsum=rcsum+rc; // sum of all %returns over time rpsum=rpsum+rp; end; call=rcsum/datapoints; put=rpsum/datapoints; Kvol=call+put; if show=result then drawline(multi*iff(showresult=percent,100*Kvol,Kvol*close),"KVOL"); hh=highest(kvol,100); ll=lowest(kvol,100); if show=rank and (hh-ll)>0 then drawline(100-100*(hh-kvol)/(hh-ll),"rank");
A graphical approach to indicator testing
The first step in algorithmic strategy design usually is to find some indicators which give you an edge and tell you something about tomorrow’s market behaviour. You could use a lot of statistics to describe this edge, but I like to take a graphical approach in indicator testing first, and only later on worry about the maths and statistics.
A scatter chart is a simple to read chart style to see the correlation between two input values. A regression line on the scatter chart gives you a visual idea if the two securities are positively or negatively correlated, the “cloud structure” of the scatter points tell you if this correlation is tight or loose.
This sample scatter shows the correlation between the DAX and DOW levels, and it can be easily seen that these two markets are tightly correlated in a positively way.
The horizontal scale is used for the second security (DAX), the vertical scale is used for the first security (DOW). This chart type is predefined in Tradesignal, just drag&drop it onto the securities on the chart and select the right amount of data to get the analysis you want to see. (eg. 2000-now). If you see a tight and positive correlation like on the chart above, It might be used to select the instrument you want to trade. If market A is easier to predict than market B, select A.
Scatter on Indicators
Although a scatter chart is usually used to show the correlation between two markets, it can also be used to show the correlation between two indicators.
The chart above shows the correlation between digital stochastic and momentum. Have a look at the clustering of points in on the right side of the scatter, a high level in digital stochastic usually goes with a high momentum. This insight enables you to get rid of momentum, as digital stochastic is easier to read than the shaky momentum. Less indicators = less parameters = less curve fitting.
Doing this analysis and getting rid of parameters is great if you want to minimise the dangers of curve fitting, but it does not tell you if your indicator is of any use at all, when it come to describing tomorrows move of the market. Surely it is valuable insight that a high level of stochastics corresponds to a high momentum, but does a high momentum today also mean that the market will move up tomorrow? And this question about tomorrow is the key question I ask myself when searching for some edge.
To get a glimpse on the prognosis quality of an indicator we will have to add some colour to our scatter chart. This colour tells me what the market has done after a specific indicator level has been reached. Green for an up move, red for a down move, black for not decided by now.
This chart shows the prognosis quality of the stochastic indicator. The left chart shows the 1 day prognosis of a 5 day stochastic, the right chart gives you the 5 day prognosis of a 21 day stochastic. Observe the clustering of the red and green dots. (black for not decided by now) As you can see on the left chart, the one day prognosis using a 5 day stochastic is not the thing to do. Regardless if stochastic is high or low, you get a nice mixture of red and green dots. This means the market, at a given stochastic level, sometimes moved up, sometimes moved down. Not this behaviour is not very useful for trading. Only in the extreme, near 0 and 100, this indicator seems to implicate a bearish next day movement.
The right chart, showing the longer term prognosis of a long term stochastic seems to be more useful. High levels of the indicator also show positive returns on the 5 days after, unfortunately you can not reverse the logic, as low indicator levels give a rater mixed prognosis. This visual analysis can give you an idea which areas of the indicator might be useful for further analysis.
A one dimensional analysis like on the chart above could also be done without this scatter chart. Going from one dimension to two dimensions is more useful, as it directly can be translated to do a kNN machine learning trading strategy. Have a look at the following chart. It shows the scatter of two indicators and the implication on the next days market move.
Lets start with he right chart. As you can see the red and green dots are evenly distributed, meaning there is no useful correlation between the used indicators and the movement of the market on the day after. If you would use a kNN algorithm with these two indicators, I would bet it would not return great results. Even if you would get a positive return, it might just be a lucky hit or curve fitting.
The opposite is true for the chart on the left. Here you can see some nice clustering of the red and green dots. Low indicator levels seem to predict a bearish move, high indicator levels result in a bullish move on the next day. A distribution like this is the perfect starting point for investing some time in a kNN machine learning trading strategy. The kNN algorithm would give you a strong prognosis with high or low indicator levels, and most probably only a weak or no prognosis when the indicators are around 50. The returns will be stable, no curve fitting problems should be expected.
Using a scatter chart can give you a nice visual indication if your indicator might be useful for a prognosis of the next days market move. This is valuable insight, as you can see the whole data universe with one glimpse, even before you do a thoroughly statistical analysis. Numbers can deceive you, pictures usually tell the complete story.
Tradesignal Equilla code:
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.
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.
When ranking a market analysts usually pick the percent performance since a given date as their key figure. If a stock has been at 100 last year and trades at 150 today, percent performance would show you a 50% gain (A). If another stock would only give a 30% gain (B), most people now would draw the conclusion that stock A would have been the better investment. But does this reflect reality?
Percent Performance and Volatility
In reality and as a trader I would never just buy and hold my position, I would always adjust my position size somehow related to the risk in it. I like instruments that rise smoothly, not the roller coaster ones which will only ruin my nerves. So ranking a market solely by percent performance is an useless statistic for me.
Lets continue with our example from above: if stock A, the one who made 50% has had a 10% volatility, and stock B, the 30% gainer, only had a 5% volatility, I surely would like to see stock B on top of my ranking list, and not the high vola but also high gain stock A.
Risking the same amount of money would have given me a bigger win with stock B.
Combining Performance and Volatility
To get stock B up in my ranking list I will have to combine the absolute gain with the market volatility in between. This can be done quite simple. Just add up the daily changes of the stock, normalized by market volatility.Have a look at the formula of this new indicator:
index(today)=index(yesterday)+(price(today)-price(yesterday))/(1.95*stdev(price(yesterday)-price(2 days ago),21))
In plain English: Today’s Vola Return Index equals yesterdays Vola Return Index plus the daily gain normalized by volatility
So if the index has been at 100, the volatility (as a 95% confidence interval over 21 days) is 1 and the stock made 2 points since yesterday, then today’s index would be 100 + 2/1 = 3
Vola Return Index vs. Percent Return Index
Lets have a look at a sample chart to compare the 2 ranking methods. I therefore picked the J.P.Morgan stock.
The upper indicator shows you a percent gain index. It sums up the daily percent gains of the stock movement, basically giving you an impression what you would have won when you would have kept your invested money constant.
The indicator on the bottom is the Vola Return Index. It represents your wins if you would have kept the risk invested into the stock constant. (=e.g. always invest 100$ on the 21 day 95%confidence interval of the daily returns)
Have a closer look at the differences of these two indicators up to October 2016. JPM is slightly up, and that`s why the percent change index is also in the positive area. During the same time the Vola Return Index just fluctuates around the zero line, as the volatility of JPM picked up during this period of time. To keep your risk invested constant over this period of time you would have downsized your position when JPMs volatility picked up, usually during a draw down. No good.
The same can be observed on the upper chart, showing the last months movements of the index. Right now, after the recent correction the percent change index is, like the JPM stock, up again. On the other side the Vola Return Index is still down, due to the rising volatility in JPM.
Vola Return Index – Ranking
Lets put this to a test and rank the 30 Dow Jones industrial stocks according to the percent return index and using my Vola Return Index as a comparison, calculated since 01/01/2015.
The first three stocks are the same, they got the highest vola and highest percent return. But JPM and Visa would get a different sorting. Just see how low the JPM Vola Index is, it would not be the 4th best stock.
Percent returns says JPM and Visa are abou the same, only the Vola Return Index shows that VISA would have been the better investment vehicle compared to JPM. But see for yourself on the chart…
Make sure your indicators show what you actually can do on the market. There is no use in just showing the percent gains of a stock if you trade some kind of VAR adjusted trading style.
Keeping you risk under control is one of the most important things in trading, and using the Vola Return Index instead of just plotting the percent performance can give you some key insights and keep you away from bad investment vehicles. Also have a look at this stock picking portfolio based on similar ideas.
Tradesignal Equilla Code for Vola Return Index:
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.
There is an apocryphal story about the famous american bank robber and jail breaker William Sutton being asked why he was robbing banks. His genius answer was “That`s where the money is”.
There is a second famous quote of William Sutton, asked why he used a machine gun for robbing a bank: “You can’t rob a bank on charm and personality,” Both quotes come up to my mind when I am asked about the key things in trading.
Sutton’s law #1: Go where the money is
I am a trend follower, just because it is easier to do than picking tops or bottoms. Robbing a bank might not be a good idea, but going where the big money is, certainly is. Big money is invested over a long time, markets are just not liquid enough so that pension funds and other big players could switch their position every day, so once a trend, or call it bullish market environment, is established, chances are great that people come in, stay in and fuel the further movements. It becomes a self fulfilling prophecy. That`s where the money is, that`s where I can do my day-to-day small scale market robbery.
Sutton’s law #2: You can’t rob a bank on charm and personality
Sutton’s law #2 is my reason for being an algorithmic traders. The market basically is a fight of everybody against everybody, all weapons and tricks allowed (well, there have been some regulations introduced..) It would be suicide to risk your money on just your charm or personal beliefs. If there is big data available, use it. If you got an algorithmic trading software available, use it. If you lose, don`t blame the market, blame yourself for not being prepared.
Seasonality changes over time!
First have a look at a screenshot of one of my favorite website investopedia.com They have some nice articles about the seasonal performance of stocks and the effects in trading. But unfortunately the information is not precise, and therefore misleading.
The chart shown suggests that the average return for the S&P500 (index or stocks?) has been positive, except for September. Further down they speak about the January effect, suggesting an average positive performance of stocks in January.
Bitcoin has come a long way but now it is time to say good bye.
Being a trend following trader on the long side, the chart right now suggest anything else but a trend following long strategy. It might all look completely different in a few weeks or months, but right now the bitcoin market is done. The ichimoku scanner indicator still shows 100% bullish, but have a look at the history and the formed indicator-market patterns: As marked on the chart we can see a nice bearish divergence. This is not a long entry signal!
Lower highs, lower lows; goodbye bitcoin, loved to trade you, but with a bearish behavior like now you are not my friend any more.
Usually we chart the market at it’s absolute level. But what, if we would just chart the net daily, weekly, monthly movement? Would this be an advantage? Would this show us new trading opportunities?
The short answer is: Yes! The trend is not everything, and it seems to be of some significance for further movements, if the market has moved more than x % from the beginning of the day, week or month.
But let’s have a look at some charts – and you will see how well it works:
The first chat is an intraday chart of EuroDollar, 8am-5pm CET. It shows you the daily net movement.
I am happy to announce that Trevor Neil will be presenting my “VIX Timing for SP500” at the next STA meeting in London.
I wrote the strategy for the IFTA conference in Tokyo and published it on this site It performed well, and now it is on Trevor to use it for educational purposes and spread the word about the advantages of algorithmic trading.
Lokale Hoch- und Tiefpunkte sind die Basis aller technischer Analyse Methoden. Durch die Abfolge dieser Punkte und deren Lage zueinander wird sowohl ein Trend als auch eine Seitwärtsphase definiert. Einzig die Bestimmung der Lokalen Hoch- und Tiefpunkte macht Probleme.
Lokale Hochs und Tiefs am Chart
Um die Umkehrpunkte am Chart zu bestimmen können Sie z.B. den Zig-Zag Indikator einsetzten. Er ist in jeder besseren Chartsoftware enthalten. Auch könnten Sie die hier bereits mehrfach erwähnte Swing Punkt Definition verwenden.
Beide Vorgehensweisen haben jedoch auch Nachteile: Der Zig-Zag Indikator verfügt eine fixe % Einstellung für die Marktvolatilität. Deshalb muss der Indikator für jeden Markt und jede Zeitebene extra angepasst werden. Die Swing Punkt Definition verwendet zwar keine Parameter, dadurch dass sich das Swing Muster jedoch nur über 3 Bars erstreckt, eignet sich dieses Kursmuster eher zur Definition von sehr kurzfristigen Hoch- und Tiefpunkten.
Swing Punkte – auto adjust
Um den angesprochenen Schwachstellen vorhandener Indikatoren abzuhelfen habe ich einen Indikator entwickelt, der diese Schwachstellen beseitigt. Er passt sich automatisch an die Marktvolatilität an. So wird es möglich den Indikator in verschiedenen Märkten und Zeitebenen ohne Anpassungen zu verwenden.
Die vergangene Woche brachte, dank der EZB, auch im DAX Veränderungen mit sich. Die Ichimoku Scanner Bewertung hat sich von +5 auf +2 (3*bull, 1*bear) geändert.
Hier die Sicht auf den DAX Index, Tageschart mit Ichimoku Indikator und der automatischen
DAX Ichimoku Scanner Analyse:
Zur Erinnerung: Der Indikator zeigt die in einer Zahl zusammengefasste Bewertung des Ichimoku Indikators. Um auf die +2 zu kommen werden folgende Punkte Vergeben:
- -1 Kurs unter Kijun
- 0 Chikou in seiner Kerze und über der Wolke
- +1 Tenkan über Kijun
- +1 Senkou 1 über Senkou 2
- +1 Kurs über Wolke
Die geglättete Version dieses Indikators hat ins negative gedreht: