Print
Hits: 3154

This article deals with an addition of the ichinscratchy system, that was introduced with version 0.2.1: A filter that enhances the quality of Kumo breakout signals. For this I owe a "thank you" to a couple of people:

Kumowizard and TA Scilab Ichimoku (you can follow them on twitter) who brought up the problem initially, and Yeara Kozlov and Tino Weinkauf, who wrote the Persistence1D library.

The article describes the problem, suggests a possible solution and describes the results of an implementation that incorporates the solution.

The problem

So, what is the problem: in sideways markets the Cloud tends to move sideways and gets thinner, too. If price is located in the same region, every spike of price outside of Kumo will trigger a breakout signal. Most of those spikes will be purely noise and thus create low quality signals with a high frequency.

Consider the following chart. In case you wonder, I removed all other signals for the sake of clarity. As you can see, the Dow Jones Transportation Index is clearly not in an uptrend, rather the price moves sideways in the bigger picture. However, on March, 10th the price spiked out of Kumo and generated a long signal. As one can see in hindsight, this was a false signal, as the index went down south.

DJTransp light nofilter

In hindsight everything looks clearer, could the quality of those signals be enhanced somehow? A good possibility to filter out such false signals would be a check, if the current Kumo breakout follows an established trend.

The Solution

If so, the long breakout should be higher than the last reaction high of the Price (and vice versa for short: then short breakout should be lower than last reaction low). I looked a while how to implement that and found a perfect solution, freely available: persistence1d- a scientific code, originally written to extract and filter Maxima and Minima from 1D functions- bingo! Have a look at http://www.csc.kth.se/~weinkauf/notes/persistence1d.html, their code is public domain, well documented and runs perfectly. 

After integrating the class into my software (which was a learning experience in itself, as the class is written in C++ and ichinscratchy uses plain C) I am now able to process price data for local extrema. Doing so for the above DJT (concentrating on the close only) gives the following local extrema (ordered by date):

 maxmins

 For those of you who can not see the woman in the red dress without the visual interface, let's plot that:

maxmin graph

This is the very same data as in the first chart, with close prices only and without any ichimoku indicators. All local maxima/minima are indicated using a green/pink bubble. I also marked the date of the above signal. As one can clearly see, the price at the signal day is not above the last reaction high as it should be, so the signal should be discarded. For the signal to be valid, it should have been at least above the level of the last green bubble, which would have meant a HUGE green candle when you try to fit that into the first chart.

Implementation into trading system

Above chart has a major flaw: It shows ALL local extrema, which also include spikes that should be considered as jitter (just look at most of February movement). In a sideways market, chances would be pretty high that the breakout signal would top the last local extremum by pure luck. That is not a flaw of Ichimoku, but a general rule: a trend following system, as the name suggests, needs an established trend to work well. It won't work in a sideways market. Garbage in, garbage out.

But fear not, the persistence1d class has a tool for that, too. As stated above, it can not only extract extrema but also filter them, based on their persistence. So roughly spoken, the longer a maximum/minimum stays an extremum and is not superseded by a higher/lower one (aka: it "persists"), the higher it is weighted. Best thing is, you can filter all extrema based on their persistence. I played around a bit with the code and came up with a pretty sane looking setting for the filter threshhold (again, thank the authors for their documented code and the included examples), which for the above example gives 6 remaining local extrema (until the signal date):

maxmin graph

The green and red lines were drawn by me, as a real chartist would do (I am none, I need the machine for that ;)) just to underline the trend, and the cancellation of it.

All that comes at pretty little cost: To speed up the process, the search for local extrema is done only once, at program startup and using all available price data. So for a 10-year or so backtest, befor looping through all days the system would calculate and store this period`s filtered extrema. As the signal evaluation code crawls through time, an additional check is done and the extrema until the current date are considered. This additional check can be activated using the following option in the config file:

ICHI_KUMO_CONFIRM = true        # check whether Kumo breakout is higher/lower than last reaction high/low

After putting everything together, and again running the code on the same period, this time with the filter enabled, the resulting graph in all it`s nakedness:

DJTransp light nofilter

 Neat. ;)

Outlook

All that started with a short discussion on twitter after I posted a signal, that originally violated the "Kumo confirmation" rule. I am so happy I found the library, ready-to-use. All my own attempts to create a code that does some similar things were awfully buggy (and slow). After integration it, I already have a bazillion of new ideas... The concept used is way to powerful to be limited as confirmation for Kumo breakouts. The very same code could be used to implement stop losses according the Dow Theory (have a kind of a trailing stop which follows the local extrema in trend direction). Or I could try a complete Dow Theory trading system. Or... or... or... the sky is the limit :)

Thx for reading, wish you relaxed trading.

Comments powered by CComment