Aggressive position sizer
The position size for each bar: a base size scaled up 2x to 8x when the explosive-momentum score is high.
The sizer runs an explosive-momentum detector on the close, volume, high and low. That detector scores each bar from 0 to 1 by combining short-term acceleration of the close, medium-term trend strength, volume against its recent average, and whether the 3, 8 and 21 EMAs stack upward, then squashes the result through a logistic curve. The sizer maps the score to a multiplier of 1x below 0.3, 2x below 0.5, 4x below 0.7, and max_mult above that, multiplies base_size by it, and clamps the result to between 0.05 and 1.0. The docstring calls this exponential, but it is a step function.
How to read it
- The line sits in its own pane below the price, between 0.05 and 1.0. Until the indicators warm up, it shows base_size.
- A flat line at base size (0.1 at defaults) means the score is below 0.3, which is most bars.
- A step to 2x, 4x or the top tier means the score crossed 0.3, 0.5 or 0.7 on that bar, and the size was set for that bar.
- A step up says the score is high, not which way price will move. Read it alongside the price's own move.
What it outputs
- Position size
- Position size for each bar: base_size times the score tier's multiplier, kept between 0.05 and 1.0.
Settings
- base_size
- Size of the lowest tier, and every other tier scales from it. Raising it lifts the whole line; at default max_mult, anything above 0.125 pins the top tier at the 1.0 cap. Zero or negative values clamp to a flat 0.05.
- max_mult
- Multiplier for the top tier, used only when the score reaches 0.7 or more. Raising it makes those bars larger until the 1.0 cap, reached near 10 at default base_size. Below 4 the top tier shrinks under the 4x tier. Zero or below clamps to 0.05.
Pitfalls
- At defaults the line is flat at 0.1 on nearly every bar (median and 95th percentile both 0.1, max 0.8), so the tiers above base size are rare on SPY one-minute bars for September 2026.
- The thresholds 0.3, 0.5 and 0.7 and the score weights are fixed in code. base_size and max_mult only scale the sizes, so no setting here makes the higher tiers fire more often.
- The size is not a trade signal: its correlation with close was -0.004 on the sample, so it does not say which way price moves.