State machine
Packs a volatility regime and a trend regime into one code, such as 21 for high volatility with trend 1.
It reads two whole-number regime values from its inputs and combines them as volatility times 10 plus trend. With both inputs in 0 to 2 the codes are 0 to 2, 10 to 12 and 20 to 22. Despite the name it has no memory: there are no transitions or hysteresis, so each bar's code is just the current two readings combined. Its meaning comes entirely from the regime indicators wired into its inputs.
How to read it
- The line sits in its own pane below the price, one whole-number code per bar, blank until both inputs have a reading.
- The tens digit is the volatility input: 0 low, 1 medium, 2 high in the ATR regime indicator this file defines.
- The units digit is the trend input; the code's comments read 0 as ranging and 1 as weak trend.
- A change in the tens digit means the volatility regime moved; a change in the units digit means the trend regime moved.
- With no regime inputs wired, the line sits near 11 times price and says nothing about regime; see pitfalls.
What it outputs
- Regime code
- Volatility regime times 10 plus trend regime, as one whole number. Blank until both inputs have a reading.
Pitfalls
- Price in, not regime: with no inputs wired, the catalog feeds the close to both, so the line sits at 11 times the close (about 8,400 with SPY near 765) and tracks price. That is the wiring, not a regime reading.
- Codes run together: a trend input of 10 or more overlaps the next volatility level, so 21 could be volatility 1 with trend 11 or volatility 2 with trend 1. The indicator does not check the range.
- Named StateMachine but stateless: it has no transitions or hysteresis, so codes can flicker bar to bar whenever an input does.