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

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

The Edge of an Entry Signal

When developing a new trading strategy you are usually confronted with multiple tasks: Design the entry, design the exit and design position sizing and overall risk control. This article is about how you can test the edge of your entry signal before thinking about your exit strategy. The results of these tests will guide you to the perfect exit for the tested entry signal (entry-exit combination)

Quality of an Entry Signal

When you develop a new idea for an entry signal there are two things you would like to see after the entry: no risk and fast profits. This would be the perfect entry with the highest possible edge. In reality the market response to your entry will be risk and chance. With a good entry the upside would outnumber the downside. Continue reading

A simple algorithm to detect complex chart patterns

Finding complex chart patterns has never been an easy task. This article will give you a simple algorithm and a ready to use indicator for complex chart pattern recognition. You will have the freedom to detect any pattern with any pattern length. It has been described as Fréchet distance in literature. This article shows a simple adaptation for chart pattern analysis.

Defining a chart pattern

Continue reading

The Edge of Technical Indicators

Classical technical indicators like RSI and Stochastic are commonly used to build algorithmic trading strategies.  But do these indicators really give you an edge in your market? Are they able to define the times when you want to be invested? This article will show you a way to quantify and compare the edge of technical indicators. Knowing the edge of the indicator makes it an easy task to select the right indicator for your market.

The edge of an indicator

Any technical indicator, let it be RSI, moving averages or jobless claims, has got a primary goal. It should signal if it is a wise idea to be invested or not. If this indicator signal has any value, on the next day the market should have a higher return than it has on average. Otherwise  the usage of no indicator and a buy and hold investing approach would be the best solution.

The edge of an indicator in investing consists of two legs.

  1. the quality of the signal
  2. the number of occurrences

Continue reading

Noisy Data strategy testing

Adding some random noise to historic market data can be a great way to test the stability of your trading strategy. A stable strategy will show similar profits with noisy and original data. If the noise has a great impact on your results, the strategy might be over fitted to the actual historic data.

Synthetic market data?

Generating completely synthetic market data to test algorithmic trading strategies is a dangerous endeavour.  You easily lose significant properties like classic chart patterns or the trend properties of your market. Continue reading

Monte Carlo Simulation of strategy returns

Monte Carlo Simulation uses the historic returns of your trading strategy to generate scenarios for future strategy returns. It provides a visual approach to volatility and can overcome limitations of other statistical methods.

Monte Carlo Simulation

Monte Carlo is the synonymous for a random process like the numbers picked by a roulette wheel. Continue reading

Overnight vs Daytime Performance & Volatility

Analysing the market performance of the day session vs. the overnight movement reveals some interesting facts.

Daytime vs. Overnight Performance

The chart below gives a visual impression on where the performance of the SPY ETF is coming from.

The grey line represents a simple buy and hold approach. The green line shows the performance if you would have held SPY only during daytime, closing out in the evening and re-opening the position in the morning. Continue reading

Bullish? Buy stock or sell put option?

So you are bullish on a specific stock, but you also have realised that timing is major problem? So what would be the best strategy to implement your bullish opinion but avoid the problems of any timing strategy?

Selling a put option might be the answer.

Bullish probability

For discussing this question let’s use the current Apple chart as an example. The question is, if you are bullish on apple, should you buy 100 Apple stocks right away or should you sell an at-the-money put option. To find the pros and cons of these two possibilities let’s have a look at some charts. Continue reading

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

Technical Analysis

Technical analysis is a form of market analysis based on historic price patterns. The basic assumption of technical analysis is, that human behaviour does not change over time, and thus similar historic market behaviour will lead to similar future behaviour. Technical analysis is a predictive form of analysis, a technical analyst will try to estimate what the market might most probably do over the next period of time. Continue reading

Market crash or market correction?

Over the last days and weeks some traders have been worried if the currently ongoing correction in the markets will evolve into a crash, or if it is just a normal correction.

Crash or correction

The main difference between a correction and a crash is the panic level. But it is not the absolute level of .VIX, the CBOE implied volatility meter. It is the difference between realized and implied volatility that defines a crash which defines real panic. Continue reading