My research seems to be moving into areas like computer science, and not beginners stuff. I have no formal training in either computer science or statistics, so that makes sense.
Price/indicator activity of a security can be separated into four states:
- Price is above an indicator
- Price is below an indicator
- Indicator is rising
- Indicator is falling
Four states is the next progression from two states. I did the two state analysis to demonstrate sufficient skill in programming and data manipulation. Once two state accounting is working properly, a good program structure should require only minor modifications to handle more complex assignments.
The Finite State Accountant logic for two state looked like this:
If Worksheets(Symbol).Cells(x1, ColX1) > 0 Then
StateX = “Above”
Else
StateX = “Below”
End If
ColX1 is a variable that contains the column number to analyze. The decision to check for a positive number is hard coded. We want to provide multiple columns to analyze and add a new type of state: Up and Down.
Another major issue is that the naming convention (eg. AM43w) quickly becomes unwieldy as more complexity is added. This is a critical issue because naming becomes part of the interface language. The interface language is used both by the developer and the programs.
The solution I came up with is to make ColX1 an array named ColX and add an array named CompX, telling the finite state accountant what state type to check. An added benefit is that the state conditions do not have to be predefined by the user. The code looks something like this:

After the current state is determined it is stored in an array for later processing. 16 states are possible with 4 column analysis ( 2 to the 4th). I think this is the simplest way keep track of distinct states.

StateXar is an array that contains states present in the data, previously I had named the possible states prior to running the accountant. The two state prototype would do something unexpected if a theoretically possible state did not happen and the program logic wasn’t aware of that possibility. This routine will handle up to 4 indicators going up/down or above/ below.

This the full column view of daily historical VTI prices and indicator worksheet. I’ve spent hundreds of hours working with various types of weighted averages and scoring systems for the indicators before deciding they weren’t saying anything special to me, so the above worksheet is streamlined.
Starting in column 7 (G) one can do a 4 state analysis on all 17 data points with the following code:

The next step is to build an evaluation system for the countless simulations that can be produced. I guess that is in the design stage.
4 State Roc1 Analysis
This 4 state Roc1 analysis is something one doesn’t often see.
I probably didn’t express this well in my SA article. Buy and Hold can be thought of as a strategy that buys all possible states of any strategy that divides the market into states. The buy and hold theory is that all states are profitable, that is, holding through them will be profitable overall. If one can show that this isn’t true for any state, that is a refutation of buy and hold for that market.

This is QQQ daily looking at R1A (Roc1 above or below zero) and R1U (Roc1 is up or down compared to the previous number). The study is considering 1248 days. During that time QQQ made a profit of $115,957 on a $100,000 investment, so the position is now worth 215,957. There were 1010 state changes during the study period averaging about 1,25 days. Note the big numbers of SMax and SMin – that seems something like the daily high and daily low summed up, which is pretty cool because it sort of tells you what you would have made or lost if you sold at the daily high or low.

AU means the previous close of Roc1 was Above zero and the value of Roc1 is up compared to the previous day. This is theoretically the most positive of the four possible states but notice it would be a money loser without this year’s price action. Note AR0 and AR1e are unfavorable while the ratio of SMin to SMax is scary.

AD means the previous close of Roc1 was Above zero and the value of Roc1 is down compared to the previous day. Note how much better this structure performs over time than AU.

BU means the previous close of Roc1 was Below zero and the value of Roc1 is up compared to the previous day. Note how similar SMax is to SMax for AD, while SMin is lower for BU. This state appears less than 10% of the time but accounts for 41% of the total profit.

BD means the previous close of Roc1 was Below zero and the value of Roc1 is down compared to the previous day. BD is the most negative state, AU is the most positive. Note TLen for all the states. the most positive state generally lasts the longest, the most negative last the second longest. The theoretical ideal is something like AU = 50%, BD = 25%, and 12.5% apiece for the intermediate states. This needs more research, but I think the state with the shortest TLen is usually the most profitable.