# Quantifying Technical Analysis

I have disavowed myself from technical analysis.

Life's too short.

Similar to Saruman however, the lure of more power is drawing me perilously close to an ancient and dark evil.

To paraphrase Nietzsche,

When you take a long gaze into the financial blogosphere, the blogosphere also gazes back into you

Prices are used in technical analysis but rarely used in statistical analyses because statistics requires that we make apples to apples comparisons.

They cannot be compared because one price is directly related to its predecessor (think of a dependent parent-child relationship).

Price *returns* (for the most part) have independent sibling relationships and they are directly comparable.

Luckily, technical analysis can be interpreted in a more rigorous way.

For example an indicator using a simple moving average could looks like this in pseudocode,

`if ( current_price - historical_prices.mean() > 0 ) buy_signal = true;`

(Javascript code for the Backtest IDE is here)

which is a weighted average of dollar differences

`DP`

can be replaced by `(DP/P) * P`

which is the simple or geometric return multiplied by the original price.

Originally, I thought the reason that the strategy might work is that while returns move randomly over the short term, they are negatively autocorrelated over longer horizons.

Often such an indicator takes 10 months or 200 days of prices into consideration and spits out a signal.

However, we see that the returns in the recent past are weighted heavier than those in the past.

There's a tension.

On the one hand the strategy is often called a 'momentum rule', i.e. large recent movements will cause further short term movements in the same direction - think of a train building up a head of steam.

On the other hand the long lookback suggests a mean reversion component where large negative or positive returns cause an elastic snapback to a long term mean.

In my next posts I hope to explore the strategy more, and perhaps come up with a more refined rule. And who knows, maybe even more profitable (although I have been spectacularly unsuccessful with that so far!).