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

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

S&P500 – when to be invested

The stock market shows some astonishingly stable date based patterns. Using a performance heat map of the S&P500 index, these patterns are easily found.

Date based performance

The chart below shows the profit factor of a long only strategy investing in the S&P500. Green is good, red is bad. The strategy is strictly date based. It always buys and sells on specific days of the month. 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

Factor investing in portfolio management

Factor investing has been around in portfolio management for some years. Based on algorithmic rules it became the big thing in trading and the ETF industry. But is there still some money to be made? Is small beta still smart or just beta? This article will give you a Tradesignal framework to test the factor investing ideas by your own.

Factor investing

Buy and hold has been a profitable approach in investing. But customers ask for more. So technical analysis came around and held up the promise that market timing is possible. As the returns did not match this promise, algorithmic trading was invented. Clearly defined rules made it possible to backtest any given strategy, and if done properly, the returns equal the ones promised during the backtest. But this requires a lot of intellectual power and relies on cheap execution, so these returns are usually not available to the public. 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

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

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 behaviour.  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 favourite 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. Continue reading

IV Percentile – when to sell volatility

Volatility trading: when to buy and 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. Continue reading

Implied vs. Realized Volatility for NASDAQ100 stocks

(1) You shall only trade when the chances are on your side

Comparing implied and realised volatility

Selling volatility can be a profitable game, but only if you sold a higher volatility than the market realises later on. Comparing realised and current implied volatility gives you an idea if the chances are on your side.

We already had a look at realised volatility and what the fair price for a straddle might be. Have a look at the kvolfair bet articles. These articles present a way to calculate the historically correct price for a straddle. Whenever you sell a straddle (to sell volatility), implied volatility should be higher than the fair bet price. Only then you will win on a statistical basis. Also have a look at the statistics of VIX, to get a clue when a downturn in volatility can be expected. Continue reading

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. Continue reading

NASDAQ 100 long term candlestick scanner

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.

read more about how to detect your own chart pattern in this article

Position sizing – the easy way to great performance

Working on your position sizing algorithm is an easy way to pimp an existing trading strategy. Today we have a look at an energy trading strategy and how the position sizing can influence the performance of the strategy.

The screenshot shows you the returns of the same trading strategy, trading the same markets, the same time frames and using the same parameters. The returns on the left side look nice, making money every year. The returns on the right side are somehow shaky, and you would have to love volatility of returns if you would think about trading this basket. The only difference between the basket on the right and on the left side is the position sizing.

The energy basket:

The basket trades German power, base and peak (yearly, quarterly, monthly), coal, gas, emissions. All instruments are traded on a daily and weekly time frame chart, using the same parameters. If the daily trading uses a 10-period parameter, the weekly trading would use a 10-week parameter. This limits the degrees of freedom I have when doing the strategy-time frame-parameter merge, thus minimizing the curve fitting trap.

Continue reading

EEX Phelix Base Yearly – Buy Wednesday, short Thursday?

When it comes to simple trading strategies, the day of the week is surely one of the best things to start with. That’s nothing new when it comes to equity markets. Everybody knows about the calendar effects, based on when the big funds get and invest their money. I do not know about any fundamental reason for the day-of-week effect in German power trading, but is seems to be a fruitful approach.

First of all I have to point out that it is not only the day of the week which is important. A strategy that just buys on Wednesdays and sells 1 or 2 days later would be doomed. But if you add a little filter which confirms the original idea, you will end up with a profitable trading strategy.

This filter will just be a confirmation of the expected move: If you suspect that Wednesday ignites a bullish movement, then wait until Thursday and only buy if the market exceeds Wednesdays high. Same for the short side, wait for a new low before you enter!

Have a look at the chart. The strategy shown buys on Thursdays if Wednesdays high is exceeded. The position is closed 2 days after the entry.

If you run a simple test which day of the week is the best to get ready for a long trade the day after then the next chart shows the return on account of the strategy using data from 2012 up to now: (exit one day after entry)

Continue reading

Opening Range Breakout

Das Opening Range Breakout System wurde im Magazin “Technical Analysis of Stocks&Commodities” im Juli 1994 besprochen, und wie es scheint, funktioniert es, zumindest ohne slippage uns Speasen, noch immer.

Ein Opening Range Breakout System von Perry Kaufmann.

Es wurde im Magazin “Technical Analysis of Stocks&Commodities” im Juli 1994 besprochen, und wie es scheint, funktioniert es noch immer. (ohne slippage) Auch Tony Crabel schrieb zu diesem Opening Breakout System im selben Magazin

Das System wartet die erste Handelsstunde ab und geht dann bei Erreichen eines neuen Hochs oder Tiefs  long oder short.  Die Einstiegs Order (Stop Buy / Stop Sell) wird nicht exakt auf das Hoch / Tief gelegt, sondern ein paar Punkte darüber /darunter. (hier 20 Ticks)

Tradesignal Programmierung des Opening Range Systems

Durch das laden von drei Zeitreihen, 10min, Stunden- und Tagesdaten gestaltet sich die Programmierung sehr einfach. Dies schränkt jedoch die Flexibilität deutlich ein.

Prinzipiell ist die Strategie der Afternoon Trader Strategie sehr ähnlich, sie weist auch mehr Flexibilität in der Programmierung auf. Auch der Artikel über Range Breaks im intraday Markt basiert auf einer ähnlichen Idee.

TSM(S) 1st hour breakout detail

Da die hier vorgestellte Systemversion  ursprünglich für dieTradestation 2000i in Easy Language geschrieben wurde, ist das Laden von 3 Zeitreihen ein wenig kompliziert gelöst. Aber es funktioniert.

Strategie Backtest mit adjustiertem DAX Future:

TSM(S) 1st hour breakout backtest

zum Opening Range Tradesignal Equilla Code Passwort “code”

Selbstlernende Handelssysteme

Ein jeder kennt die klassischen Indikatoren wie RSI oder Stochastic. Und ein jeder kennt die dazugehörigen Handelsanweisungen: Long, wenn überverkauft, Short wenn überkauft. Und zumindest im Lehrbuch funktioniert das auch. Aber wie sieht das ganze am realen Chart aus? Würden Sie dem Lehrbuch vertrauen und Ihren Kunden auch einen baldigen Kauf empfehlen wenn der RSI unter 20 liegt?

Testen anstatt zu studieren

Schön, wenn ein Indikator im Lehrbuch funktioniert, doch will ich hier ein Verfahren darstellen, bei dem der Indikator selbst angibt ob, wann und wie gut er funktioniert! Dazu habe ich mir für diesen Beitrag den RSI Indikator vorgenommen.

Zunächst wird der Wert des Indikators betrachtet, sowie, ob er steigt oder fällt. Mit diesen beiden Kriterien lässt sich der RSI einfach klassifizieren.

RSI Prognose

Dann erfolgt der eigentliche Backtest: Innerhalb der letzten 1000 Bars wird nun geschaut, wie sich der Markt bei einem gleichen Indikatorstand (zwischen 90 und 100) und Richtung (über Triggerlinie) verhalten hat.


Am Bild kam dies innerhalb der letzten 100 bars 36 mal vor. Dabei war die durchschnittliche Bewegung innerhalb der darauffolgenden 5 min DAX Futures Kerze -0.03%. Der RSI hat beim aktuellen Stand also eine negative Kurs Prognose.

Dass es auch nach dem nächsten bar statistisch nach unten geht, sieht man an den 5 Prognose Punkten am Chart. Sie zeigen, wie sich der Markt statistisch innerhalb der nächsten 5 Bars verhalten hat, unter der Bedingung, dass der RSI den aktuellen Stand und Richtung hatte.

Markt Performance als Indikator

Der obige Screenshot zeigt den Indikator und die Prognose für den kommenden bar (sowie die 4 darauf folgenden). Er zeigt jedoch nicht, wie sich diese Prognosen in der Vergangenheit verhalten haben, in welchen Bereichen der Indikator in der Vergangenheit seine höchste Aussagekraft hatte. Dies ist am nächsten Chart dargestellt.

RSI Prognose

Am Bild ist unter dem eigentlichen RSI seine aktuelle prognose für den nächsten Bar dargestellt. Um diese prognose ist ein Bollingerband gelegt, um so die Bereiche zu definieren, an welchen der RSI seine höchste Aussagekraft hat (= die stärkste Bewegung vorhersagt)

Continue reading

Reality vs. Robert W. Colby, CMT

Dont`t believe!

Papier ist geduldig, darum ist es oft besser wenn man selbst testet bevor man ein veröffentlichtes Handelssystem mit seinem Geld ausprobiert. Heute geht es hier um einen Handelssystem out of sample Test

Ein schönes Beispiel dafür ist eine Strategie aus Robert Colbys Buch “The Encyclopedia of Technical Market Indicators“, 2nd edition, 2003, page 791ff.

Darin wird ein einfaches moving average crossover Systeme vorgestellt, welches anscheinend seit beinahe 100 Jahren phänomenale Gewinne verspricht.

Hier eine Kopie aus dem Buch:

colby wma strategy


Tradesignal Backtest

Continue reading