Monday, April 7, 2014

May the Math be Ever in your Favor

I have occasionally seen trading system ideas that I feel incorporate unnecessary risks.  I'm not saying the signal will not work, but rather, there is an element of randomness to them.
It is common to build systems that look for one or more indicators crossing above or below the prices or some other indicator.  However, sometimes such a system may look good but have a hidden vulnerability.  Consider the chart below: 

Willilam's %R and the Chaiken Money Flow(CMF) are common indicators.  Normally, they are used separately, however, if we overlay the CMF in the plot of the Williams %R, it looks like we have found a good signal:

Notice how the Williams %R seems to cross above the CMF at the start of up moves.  The opposite signal does not seem as good as it is sometimes delayed.  However, the chart above shows two long signals that should be profitable and a third that could have made money depending on the exit signal.  But is this really a good system?

Formulas require a mathematical test to find buy and sell signals.  The possible signals above are easily seen, but mathematically, the systems did not cross.  Here is the same chart with the indicators merged to use the same scale:

The CMF is essentially a flat line compared to the Williams %R.  Additionally, it's never really  very far from the zero line.

There are some calculations that try and normalize the scales of the two indicators. However, this logic is only accurate for the last bar displayed on the screen.  It also requires an exact specification of how many bars are visible in the chart.  This means any signals you get may not match what you see in your chart.  Consider the following two charts:

Both show the overlaid indicators for the Months of October and November.  The top chart shows data up to November 22nd.  The Williams %R is firmly below the CMF but has just risen to touch it for the second time.  The second chart adds another 8 days of data.  Now the CMF hugs the Williams %R, even whipsawing above it on November 4th.  It also shows a buy signal on 22 November that we did not take because it was not there on that date.

Sometimes a system that is overlaying indicators can resolve the math issue with a minor change to one of the indicators.  For example, the Williams %R usually plots in the -100 to 0 range.  If you add a constant to this, you can shift the range.  For example, adding 100 to the Williams %R will change the scale from -100 to 0 to 0 to +100.  The shape of the curve is the same but the values have been shifted.

In the chart below, I created a custom formula to add 50 to the Williams %R.  This shifts the scale so it is centered on the zero line like the CMF.  I also multiplied the CMF by 100 so it will have more visible swings when compared to the Williams %R:

The other advantage is that this will not change.  The value for any given bar will always be the same.  When the scales are fixed and not subject to the whims of zoom settings, it will remove one more chance for a trade to go against you.  Keep the math in your favor and your trading should be better. 
Post a Comment