Trend direction regime
Whether the fast, medium and slow averages are stacked up, stacked down, or tangled: +1, -1 or 0.
TrendDirectionRegime takes exponential averages of the close over three periods, fast, medium and slow, which default to 10, 20 and 50 bars. It outputs +1 when the fast average sits above the medium, the medium above the slow, and price above the fast average. It outputs -1 for the mirror case and 0 otherwise, so it is a three-level trend label rather than a price line, and it has a value on every bar.
How to read it
- The line sits in its own pane below the price and only takes -1, 0 and +1, so it reads as a step chart.
- +1 means the averages are stacked up and price is above the fast one. -1 is the mirror image: stacked down, with price below the fast one.
- 0 covers everything else: the averages are tangled, or stacked but price sits on the wrong side of the fast average.
- On the September 2026 SPY sample the line reached -1 and +1 on at least 5% of bars each, and its median reading was 0, so the middle of the sample was sideways.
What it outputs
- Trend direction
- +1 when the averages are stacked up with price above the fast one, -1 when stacked down with price below it, 0 otherwise.
Settings
- fast
- Length of the fastest average. Raising it, say to 20, lags more and needs a steadier move to line up, so 0 holds through short swings. Lowering it, say to 5, flips the reading sooner. Keep it below medium, since the up and down tests assume that order.
- medium
- Length of the middle average. Raising it delays the stack, so +1 or -1 needs a longer, cleaner trend. Lowering it lets the stack form on shorter swings. Keep it between fast and slow.
- slow
- Length of the slowest average. Raising it, say to 200, makes the anchor lag, so the stack lines up only on sustained moves. Lowering it, say to 25, keeps the anchor near price so the stack reacts sooner.
Pitfalls
- The averages seed from the first close with no warm-up. At the default slow length of 50, the first close still carries weight for about 100 bars, so the start of a loaded history is the least reliable.
- Nothing smooths or confirms the reading. The line is recomputed every bar with no hysteresis, so price crossing the fast average can flip +1 to 0 and back on one-minute noise.
- The copy routine behind Pipe.copy() rebuilds the indicator with fixed 10, 20 and 50 periods, so a copy ignores the periods you set.