Adaptive explosive sizer
Sizes a position from a regime code and an explosive-move score; on SPY with default inputs it stays flat at 2.
The output is a position-size multiplier. It starts from a regime multiplier (regime 2 gives ×4, regime 1 gives ×2, regime 3 gives ×0.5, any other value gives ×1) and scales it by the explosive score (8 or more gives ×2, 6 to under 8 gives ×1.5, 4 to under 6 gives ×1.2, under 4 gives ×1). The product is capped at max_size and never falls below 0.5; if the score, regime or close has no value yet, it returns base_size. The class docstring mentions recent performance and volatility, but the code uses neither.
How to read it
- The line sits in its own pane below the price. It is a size multiplier, so 2 means twice the base unit.
- On SPY one-minute bars with default settings it is flat at 2 across the whole sample, so it shows nothing about the market.
- Its score and regime inputs have no default, so with nothing wired in the chart feeds both the close price. A price matches no regime code (×1) and reads as the top score tier (×2).
What it outputs
- Size multiplier
- Position size multiplier, never below 0.5 and never above max_size. Flat at 2 on SPY with default settings.
Settings
- max_size
- The ceiling on the multiplier. The formula tops out at ×4 × ×2 = 8, so raising it above 8 changes nothing. Lowering it clips the top: at 1, the flat line on SPY drops to 1.
- base_size
- The size returned while the score, regime or close has no value yet, such as during warm-up. On the chart those inputs take the close price, which always has a value, so changing it shows no difference there.
Pitfalls
- The docstring promises recent-performance and volatility adjustments the code does not make. Its entry-price and peak-profit fields are set and reset but never used to size.
- Any regime value other than 1, 2 or 3 counts as consolidation (×1), so a regime indicator that outputs prices or other codes sizes without any warning.
- It gives a size, not a direction. A high multiplier does not say whether to buy or sell.