# Specter: A Finite State Trading Strategy

## Summary

- Specter, a finite state trading strategy is discussed.
- Natural logarithms of return should be used in algorithm design and performance analysis.
- An appreciation of high dimensional probability concepts is important in analyzing price action.

It's your spectre against mine.James Bond, Thunderball

## The Legend

My previous article on Finite State Accounting, noted some technical flaws in current strategy evaluation models and proposed a framework to correct them.

Data science is the most important discipline for analyzing securities prices. Design flaws are revealed as an application grows in complexity. This does not indicate an error by the architect, but are a natural consequence of increased complexity. Failure to make regular design improvements results in stagnation and inhibits the creativity of application users.

Application designers of the past have produced deep and admirable work but it is a mistake to canonize something that must change over time to remain viable.

## Introduction To Specter

In this article, I will outline a simple finite state strategy that has produced interesting results for the last few years.

The strategy is called Specter - a visible disembodied spirit.

In a normal moving average above strategy, a long position is taken if the current price of an equity is higher than a given moving average; Specter takes a long position in a different equity if the current price of a map symbol is higher than one of its moving averages.

As described in FSA, price data for an equity is stored in a detailed worksheet with the same name as the equity.

For example, worksheet UNH shows:

C*reated by the author with data from Norgate*

WPrice = (Open + High + Low + Close + Close) * .2 This is used to calculate the averages. Note - the exact nature of a final price won't make or break a strategy, but it is probably better to use some kind of weighting if only because the close can be manufactured to some extent.

R01 = One-day rate of change.

The one-day rate of change is quickly becoming obsolete in FSA. The application now uses the natural logarithm of the one-day rate of change.

Moving averages are stored using the formula:

(WPrice - Average) / Average. If price is greater than the average, this number will be positive.

A sample list is presented below:

C*reated by the author with data from Norgate*

In a traditional simple moving average above strategy using M04, a long position would be entered at the close when M04 ( (WPrice - Average) / Average ) becomes positive on Feb 4. A long position is taken at the Feb 4 close, the position is exited at the close on Feb 7 when the number turns negative.

Instead of looking at the UNH averages, Specter looks at those of the map symbol. The specific map symbol is a variable. SPY seems to work best as the map symbol ($SPX is equivalent) even when analyzing sectors.

The map situation is illustrated below:

C*reated by the author with data from Norgate*

In this case, $M04 is used instead of M04. $M04, etc., is M04 mapped from SPY. Specter is an abstraction of the indicator data from the map symbol.

## Performance Summary

Much of my recent work has focused on range analysis and data presentation. The range is an abstraction of the daily open low high and close extended to longer time periods. A chart is not a real good way of looking at data (granted it is a real simple way) because it basically shows only price and an expression of time for a single security. Time, as the horizontal axis on a chart, is a bit strange; length of time is not the same as length in inches for example. The chart sort of tells you that it is.

For example, one can use time to accurately graph a car's acceleration from 0 to 60. That concept of time is far different than financial time.

A listing is a more efficient way of conveying orders of magnitude more relevant information, despite a picture being worth about 1024 words. The process of building the performance summary is discussed below using my favorite ETFs.

C*reated by the author with data from Norgate*

The start and end dates for the study are on the top line. The start price is the closing price of the start date and the end price is the closing price of the end date. The high and low are the highest high and lowest low achieved during the time period, in this case 540 trading days.

The price numbers get transformed to range and return data below:

C*reated by the author with data from Norgate*

Return = (EndPrice / StartPrice) - 1

LogRet = Natural log of EndPrice / StartPrice

MaxLr = Natural log of High / StartPrice

MinLr = Natural log of Low / StartPrice

Tmm = High / Low

Amm = (EndPrice - Low) / (High - Low)

## Natural Logarithms

It took me about 45 years to understand this. Natural log returns are pretty much absolutely essential for algorithmic development. Academia claims both are equivalent but this is far from true if one is a developer.

More information is stored in a log return. A log return can be summed and averaged. Normal returns can't be easily accurately summed and averaged; for example, a 10% gain plus a 10% loss does not equal 0. The Log Return of 21 on the bottom line is an absolutely accurate number while the 25 for the Return average is not. The ETFs returned about 10.5% per year compounded (10.5 + 10.5 = 21) during the time frame.

Another big technical advantage of accepting natural logs is that a strategy can be back-tested and analyzed without the overhead of creating a trade listing. The studies presented here do not use a trade listing.

Unfortunately, accepting natural logarithms requires going through (and understanding) a song and dance mostly centered on why 1 (Return) and .69 (Natural log of return) are the same number.

## Volatility

Predicting volatility is beyond my skill, mainly (I hope) due to the elusive nature of financial time.

MaxMin analysis is a simple way to assess price fluctuations. MaxLr indicates something about upside volatility and MinLr downside. More than one time period should be considered when assessing MaxMin. In the list above, QQQ has a Max of 42 and Min of -9. Clearly, this is a favorable reading but at some points during the period, substantial losses were incurred.

Tmm is a volatility measure that doesn't look directly at flapping. My latest guess is that volatility is multi-dimensional.

Amm is important to understand in trading. Ordinarily, a long position can be taken sort of randomly and the normal trading activity is to sell near MaxLr with the idea of buying again after a pullback. That strategy has been a serious misreading of the situation for the last few years because Amm has been appearing too close to MaxLr. That resulted in limited opportunities to buy back at lower prices.

ETF results for the strategy are presented below.

## ETF Results

C*reated by the author with data from Norgate*

$E indicates an exponential moving average while $M is a simple moving average.

I have done a lot of work on exponential and simple moving averages; exponential averages are not better than simple averages. Fortunately, for EMA aficionados, they are also not clearly worse. The main practical difference between the two is that the slope of an EMA is positive if the price is above the average and negative if it is below; a fact that seems more interesting than useful.

Note that returns are about equivalent between $E and $M. $E04 and $E09 have the best returns for $E while $M09 and $M16 lead $M.

It is very difficult for a strategy to beat buy and hold, especially as the time frame gets longer. This does that in a remarkable number of cases.

A huge advantage of using natural log returns is that if one knows the total return, only the above return needs to be known to derive the below return. For example, SMH made a log return of .44 (that is multiplied by 100 to drop the decimal point on the listing). $M09A made 51. That means that $M09B (B for Below) made 44 -51 = -6.

A few offhand remarks:

XLE performed substantially better than buy and hold for the shorter term above conditions.

XLF wasn't a buy and hold nightmare like XLE but it doubled its return using $E04.

XRT almost achieved respectability with several specter returns.

QQQ and XLK performed well under all conditions, SMH did better using favorable Specter lengths.

The listing shows that XLU, XLP, and my favorite SPLV performed well in B situations. That is why it's often a good idea to head to those places when things turn sideways.

## Dow Jones Industrial Component Performance

Dow (DOW) and The Travelers Companies (TRV) have been dropped from the list, DIA and SPY are added.

C*reated by the author with data from Norgate*

Note Microsoft (MSFT) more than doubled but the log return is 81, while Apple (AAPL) almost doubled and its log return is 65.

We see a similar distribution of profits ($E 04 and 09, $M 09 and 16) with that of the ETFs.

The number strings themselves are important. I think this gets into an area of research known as High Dimensional Probability:

Data sciences are moving fast, and probabilistic methods often provide a foundation and

inspiration for such advances. A typical graduate probability course is no longer sufficient to acquire the level of mathematical sophistication that is expected from a beginning researcher in data sciences today.

Pretty cool to get a glimpse of it and too bad you can't just run a tape for a few seconds to master it like Trinity with the Helicopter in Matrix. The highlighted phrase, I think, points to the need to encourage creativity and that data science promotes that.

## Normal Moving Average Performance

C*reated by the author with data from Norgate*

Normal moving average performance was "normal" for this group during the period. That is, returns are more or less equally divided between A and B states. Some equities have some possible return streams that exceed buy and hold, in some part due to avoiding much of the several sharp market declines during the period.

A bull market is in an A (above) state about 2/3 of the time. B states make about as much money as A states in less time, at the price of increased risk.

## Prior Performance

C*reated by the author with data from Norgate*

The returns from Specter from the prior 540-day period were not as spectacular as the most recent. However, they are certainly interesting enough to consider.

Note how DIA gets an unusually large part of its return when SPY is in an above state. Coca-Cola (KO) and Procter & Gamble (PG) deserve attention because they consistently seem to get most of their return when SPY is below.

There seems to be some persistence over time with equities that perform well in either an above, below or mixed environment.

## General Remarks

I'm not aware of any other time period where Specter performs close to the level shown for the previous few years.

There are several important issues regarding attempting to play the strategy:

- There is an embarrassment of riches on a buy signal with too many favorable stocks to choose from.
- The favorable price action suggests speculation has been rewarded for short-term index breakouts. That is historically unusual - shorter time periods (e.g. 220 days vs. 540) show some deterioration in returns.
- The current advance has been pretty remarkable in that it is hard to see excess, at least through traditional tools. This action strikes me as unhealthy and probably excessive, but there is no time table for the party to end.
- Be careful when confronting a Specter.

This article was written by

**Disclosure:** I/we have no positions in any stocks mentioned, but may initiate a long position in SPY over the next 72 hours. I wrote this article myself, and it expresses my own opinions. I am not receiving compensation for it. I have no business relationship with any company whose stock is mentioned in this article.

**Additional disclosure: **Have been hedging SPY with ITM calls