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

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

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

An Algorithmic Stock Picking Portfolio

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

Alpha and Beta

Investing in assets with low volatility and high return is on a lot of peoples wish list. Portfolios which archive this goal will have a high Sharpe ratio and in the end get the investors money. By reverse engineering this criteria, one can find promising stocks to invest in and out perform a given capital weighted index.

Alpha and beta are measures to describe an assets performance relative to its index. Both are used in the CAPM – capital asset pricing model.

Alpha is a measure for an assets excess return compared to an index. Continue reading

Weis Wave indicator code for Tradesignal

The Weis Wave indicator combines trend and volume information. It seems to be of some interest for timing short term market reversals. Here comes a version of this indicator for usage in Tradesignal.

The Weis Wave indicator for Tradesignal

The basic idea of the Weis Wave indicator is to sum up the traded volume, as long as the market moves in the same direction. The bullish volume wave is displayed in green. As soon as the market changes direction, a red wave is constructed. by comparing the magnitude of the Weis wave with the magnitude of the market move, valuable insights for short term market timing can be found.

More information can be found via a web search or from the page I got the idea form: https://weisonwyckoff.com/weis-wave/ Continue reading

Tradesignal Implied Volatility and IV Percentile Scanner

Implied volatility data is key in options trading. This article shows how to access free volatility data in the Tradesignal software suite.

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 implied volatility 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 Continue reading