Detecting Excess Market Moves

Sometimes markets move too fast and too far. This article is all about a new method to detect excess market moves. A new indicator will be presented, which overcomes many of the downsides of traditional ones like RSI or Bollinger Bands.

Overbought and Oversold Indicators

I am sure you are familiar with the traditional indicators RSI and Bollinger Bands. Legions of analysts have used them to detect excess market moves and market reversals. You might have used a RSI reading above 70 or below 30 or a market close outside of a 2 standard deviation Bollinger Band to do so. But these traditional indicators have a big downside: they are always calculated over a given period of time: 14-bar RSI, or 20-bar Bollinger Bands. You can surely adjust this setting to your market, but who tells you that e.g. a 17-bar calculation period is better than taking the last 14 or 20 bars into account? Going this way is a slippery road and you might fall down the cliffs of curve fitting.

classic excess indicators

classic excess indicators

A new algorithm for excess detection

Bollinger Bands already has the key ingredient for a useful reversal detector: it measures the market move in standard deviations. But it does the measure only over a fixed interval setting, thus missing a lot of shorter or longer excess market moves.

To overcome this restriction and find all excess moves, I did me an indicator which searches for excess moves over multiple intervals. This is how it works:

First the algorithm calculates a volatility measure. All data on the chart, prior to the testing bar, is used. The formula used is described over here. After the volatility of the market has been calculated, the algorithm measures all market moves for a given number of bars. A standard setting might be to calculate all moves between 5 and 200 bars. From this list of moves, normalised in volatility multiples, the algorithm picks the biggest moves. Then a trigger value is applied and the algorithm checks if the biggest move found is more than e.g. 3 times the expected volatility. To show the found move on the chart, the algorithm waits for another bar, and if this bar does not form a new low for bearish moves or a new high after a bull move, the move is shown on the chart. A reversal or at least an end of the exuberant market move can be expected.

market excess detection

market excess detection

On the chart above you see this new indicator in action. The right chart is Bitcoin on an hourly timeframe, the right one is German power on a daily timeframe. Both charts use the same settings and search excess moves with a length of 5 to 200 bars. The lines are fixed (confirmed) with a 2-bar counter move.

Some examples for excess detection indicator

To see the effect of different settings have a look at the chart below. All 3 charts detect moves between 10 and 200 (hourly) bars. A 1 bar confirmation delay is used. The difference between the charts is the minimum volatility multiple which is used to detect the excess. From left to right it uses a 1, 3 and 5 times the average fair bet volatility to define the minimum move.

Kahler excess detector - different settings

Kahler excess detector – different settings

Statistical test of excess indicator

If this indicator is any useful, the market should show a different behaviour on the bars after an excess move has been detected than on an average day. To see if this is true the signal efficiency can bet tested using the methodology described in an earlier post.

excess detector test

excess detector test

The chart above shows the excess detector applied on daily JPY Forex data. Only bullish reversals are detected. On the right side you see the average profit factor for the days after a reversal (2*vola, 1 bar confirmation) has been detected. Although it has been a falling market (magenta benchmark below 1) the signal generates showed an average profit factor of more than one – a strong indication that this indicator is able to predict a bullish move after a sell off has been detected. Even in an overall bearish market.

Usage and general thoughts

There is no indicator which will tell you what the future will bring, but a good indicator will flash a warning sign if the current state of the market is going to change. My excess indicator, like Bollinger Bands and RSI, will tell you when the markets have moved too far. It does this detection independently from a fixed period setting. You have to decide which timeframe you are interested in, e.g. short term = 3 to 10 bars, mid term=10 to 21 bars, long term=21 to 200 bars, and then use the signals of this indicator as a setup to your trading strategy.

If the indicator tells me that there has been an excess bearish move, I will not set up a new short position. I neither would set up a long position if this sell off happened in a bearish market. But I will think about using a tight trailing stop to lock in the profits of my short position.

If there has been an excess bearish move in an uptrend, I might want to start to scale into a long position, using a tight stop loss at the beginning and the let it run until my indicator flashes a warning sign in the other direction.

Never forget that money is made with position sizing and risk management, although a nice indicator can help… :)

Tradesignal Indicator Code

You can download the source code of this indicator as a txt file. Copy and paste the content of the text file into a new indicator in Tradesignal and start exploring.  You will need the latest version of TS (10.2) and have a chart with at least 1000 bars of data. By downloading the indicator you are accepting the smallprint.

Kahler’s Excess Detector

 

A self optimising moving average

Different markets and different timeframes will need different moving average periods. This article will show a way to construct a self optimising moving average, one which automatically adjusts its period to the charted market and timeframe.

Reading a simple moving average

I would like to start this new indicator with some thoughts about how to define how “good” a moving average is. Usually my (simplified) standard interpretation of a moving average is, that when it rises and the market trades above the average, I am in bullish mode and would expect the market to rise over the next  bars. This very simple interpretation of a moving average can be quantified, meaning that I can calculate a measure to judge if my assumption is any good. To do so, I just count the number of bars which have been rising and falling while (initial condition) the market has been above the average and the average has been rising. This will give me a number, and let’s say on 52% of the bars in history when the initial condition was met, the market rose on the day after. As the chance is better than 50%, I would conclude that the analysed average is a useful one.

Self optimising moving average

Instead of just analysing one specific moving average length one could calculate the metrics for all moving averages. The sample implementation (code at the end of the article) will calculate all moving averages within a given parameter range (eg. 5 bars to 200 bars), calculate the winning percentage (rising bars) on the next bar, and then pick the best performing period length.

self optimising moving average

self optimising moving average

The moving average on the chart above constantly changes its period to the period, which would have given the best indication in history. As the original criteria has been to maximise the percentage of up-moving bars when the market is above the average and the average is rising, the shown moving average will always be the one which will give you the highest probability of a rising bar (next bar) if the average is rising and the market is trading above it. These periods are shown in green. Otherwise, if the criteria is not met or the winning percentage is below 50 (=no average has a better than 50:50 prediction capability), the indicator is colour coded red.

Advantage of the perfect average

Beside plotting the best moving average, one could also plot the statistics of the best moving average. This would be the percentage of winning bars when the original criteria is met.

best average statistics

best average statistics

The chart above shows a comparison of 3 different timeframes. A daily, hourly and 5 minute chart. The indicator below shows the edge the best moving average would give when trying to predict rising bars. A level of 5 would mean that you got a 55% chance for a rising bar when selecting the best performing period for your moving average and the average is rising and the market trades above it.

Using the self adjusting average this way, you can easily see in which timeframes or markets a moving average prediction model would be useful. On the chart above you obviously do not want to use this simple indicator interpretation on a 5 minutes chart. If the indicator is colour coded in red, either the market is not trading above the best average, the best average is not rising, or it would give no edge when trying to predict the next bars move.

Stability of results

As the indicator is based on a statistic over a given period of time, we have to think about stability and outliners. To remove outliner results, the statistics are smoothed. Instead of taking the winning percentage for a given average length, also the 2 results to the left and right are taken into account. The indicator can also plot these smoothed results, so you can see the edge the average prediction would offer with different periods.

On the chart below, the magenta histogram on the right shows the historic edge (smoothed) over the tested periods for the averages. From length 7 to length 148 all results would have been positive (a better than 50:50 chance for a rising bar), the best result was obtained with a period of 31. Observe this with different lengths of history, and you will get a good guess if your market is the right one for this kind of analysis. If the edge is not above 50% with a lot of periods, then this prediction will hardly be useful.

best period average complete

best period average complete

Link to indicator source code

Find the indicator code over here. The code is written in Equilla, the scripting language of the Tradesignal software.

The indicator uses all available data on the chart to calculate the statistics. You can set the range of periods you want to analyse. If you would like to backtest the indicator (go long when green) then just add the line below at the end of the code (used as strategy)

best period average backtest code

best period average backtest code

Continue reading

Z-Score Factor Portfolio Weighting

Technical Indicators can be used for timing and weighting strategies. Using momentum as an example, you could go long if the momentum turns positive, or you could dimension the weight of your position depending on the level of momentum. Applied on a portfolio of assets, this would be called factor investing. This article will show you a way to weight your portfolio using factors. Continue reading

The coastline paradox and the fractal dimension of markets

Coastlines are fractal curves. When you zoom in, you will see similar shaped curves on every scale. The same is true for market data. On a naked chart you can hardly tell if it is a daily or hourly chart. This article will explore this feature of crinkly curves and show how much markets and coastlines have in common.

The coastline paradox

When trying to measure the length of the British coastline you will quickly notice, that the length measured depends on the length of the ruler you use. The shorter the ruler, the longer the measured length of the coastline.

When measuring a straight line, the length of the ruler has no influence. You can measure 1 meter with a 1cm ruler applied 100 times or with a 50cm ruler applied 2 times. Both methods will give you the same result. Not so when measuring a crinkly line like a coast.

British coastline length paradox

British coastline length paradox (c) wikipedia

In 1967 Benoit Mandelbrot wrote a famous article in Science magazine about this problem. This was the birth of fractal geometry. The basic assumption was, that if a curve is self similar, this self similarity can be described by the fractal dimension of a curve. Self similarity means, that if you zoom into a curve, it looks similar on all zoom levels.

Coastline paradox in financial markets

Continue reading

Detecting Support and Resistance Levels

Support & Resistance levels are essential for every trader. The define the decision points of the markets. If you are long and the market falls below the previous support level, you most probably have got the wrong position and better exit.

The detection of support and resistance levels is usually highly subjective and based on the analysts experience. In this article I will use a simple algorithm to detect the levels and show them on the chart. Continue reading

Profit from large daily moves

Whenever the market shows an exceptional day ranges it is time to take bite. See how you can profit from large daily market moves.

Open-Close Range

When looking at any chart, you will surely notice that the large candles tend to close near the high or low. This is due to herding. Once the market is moving significantly, everyone hops on and the large move becomes even larger. This is true for daily, weekly and intraday candles.

The chart shows an indicator which plots the daily move. Every opening is set to zero and the absolute move of the day is drawn. Around these normalised candles a long term 2 standard deviation volatility band is drawn.  Right now the 2 standard deviation volatility for SPX is about +/- 46 points.

Take a bite before the market closes

As you can see this +/-46 point barrier above/below the opening of the day is a wonderful entry point. If you enter long 46 points above the opening and go short 46 points below the opening nearly all entries would have lead to a profitable trade. To get an even higher probability of success you can volume as a confirmation. Large moves must also show high volume. The exit is done at the end of the session. This analysis does not give any indication for the next days move. So be fast, take your bite and go home with a small profit and no overnight position.

No free lunch

On the chart it looks easy, but be careful. As an example the last bar shown on the chart first crossed the band to the downside, reversed and crossed above the upper band. So you will need to use a trailing stop to lock in profits and avoid to take the full -46 to +46 points trade as a loss!

 

 

 

 

Python Regression Analysis: Drivers of German Power Prices

German Power prices can be explained by supply and demand, but also by causal correlations to underlying energy future prices. A properly weighted basket of gas, coal and emissions should therefore be able to resemble the moves of the power price.  This article will introduce multivariate regression analysis to calculate the influence of the underlying markets on a given benchmark. It is an example of  a machine learning algorithm used in analysis and trading.

Multivariate regression analysis

Continue reading

RSI Hellfire Heatmap Indicator

Chart analysis is all about visualizing data. The RSI hellfire indicator uses a heat-map to visualizes how overbought or oversold the market is on a broad scale. This helps to get a broad picture of the current market setup.

Multiple Time-frame Relative Strength Index

Wells Wilder’s RSI is an old timer of technical indicators. It tries to find out if markets are overbought or oversold. Usually it is calculated using a 14 bar setting. But a 14 bars RSI on a daily chart will give a different reading than 14 bars on an hourly or weekly chart. As it is always nice to see what traders on a different time-frame see on their charts, you could simply display several RSI settings on your chart. Continue reading

VIX Futures spread trading

VIX futures are usually in contango, meaning that the next month future is quoting at a higher price than the current month VIX future. But this spread in not constant, and at the end of the expiry cycle an interesting VIX future spread trading idea comes to my mind…

End of cycle VIX futures spread trading

Having a look at the chart below you hopefully see the spread trading idea by yourself: Continue reading

How to detect unwanted curve fitting during backtest

Whenever you develop an algorithmic trading strategy, unwanted curve fitting is one of the most dangerous hazards. It will lead to substantial losses in real time trading. This article will show you some ways to detect if the performance of your algorithmic trading strategy is based on curve fitting.

Curve fitting – what is it?

Every algorithmic trading strategy will have some parameters. There is no way around it. You will have to decide what length your indicators have, you will have to specify a specific amount for your stop loss or profit target. Beside the actual rules of your strategy the chosen parameters will usually significantly influence the back-test performance of your strategy. And with any parameter you add the danger of curve fitting rises significantly. Continue reading