Momentum classifier
A 1–5 momentum class (1 strong up, 5 strong down) that often follows recent volume as much as price.
MomentumClassifier scores each one-minute bar from three terms: the short-window average of closes against the long-window average (weight 0.5), the move from the oldest close in the short window to the latest (weight 0.3), and the last five volumes against the short-window volume average, minus one (weight 0.2). The weighted score falls into one of five buckets, cut at ±0.005 and ±0.015, and is returned as 1 (strong up) through 5 (strong down). On one-minute bars the two price terms are small while the volume term swings much more, so the bucket often tracks volume as much as price.
How to read it
- The line sits in its own pane below the price and takes only whole values from 1 to 5.
- 1 is strong up, 2 weak up, 3 neutral, 4 weak down, 5 strong down. A move toward 1 means momentum is turning up; toward 5, turning down.
- Neutral (3) is the typical reading on SPY, with a median of 3; both 1 and 5 each cover at least 5% of bars.
- At default settings the first 49 bars read blank while the 50-bar long average fills.
What it outputs
- Momentum class
- Whole-number class from 1 (strong up) to 5 (strong down), built from price trend and recent volume. Blank for the first long-window bars.
Settings
- short_window
- Lookback for the short average, the recent move and the volume average. Higher is smoother and slower to switch; lower reacts within minutes. Below 5, the volume term turns off.
- long_window
- Lookback for the long average, the baseline the short average is compared with. Higher is slower and adds blank bars at the start. Keep it at or above short_window, or a rising price pushes the price term negative.
Pitfalls
- The name says momentum, but on one-minute bars the volume term often sets the class; the sample's correlation with close is near zero (-0.007).
- The scale runs backwards from most indicators: a line rising toward 5 means momentum is turning down, not up.
- Volume bursts, such as news or the open, swing the volume ratio and can change the class with little price move.