Rounding top setup event
Flags a possible rounding top: the moving average turns down while Bollinger width has been narrowing for a run of bars.
A rounding top is a slow turn-over after a rise, when momentum fades and volatility tightens. This indicator checks two things on each bar: the EMA of close (ma_window, default 50) is lower than on the bar before, and the Bollinger band width (upper minus lower, divided by close, over width_window bars) has narrowed for width_drop_n bars in a row (default 10). The code tests only these two conditions at that moment; it does not check the shape of the top or any earlier rise, and it reads close alone although highs and lows are passed in.
How to read it
- Markers sit on the candle where the width squeeze reaches the required run length while the average is falling.
- A squeeze longer than width_drop_n bars fires once, on the bar it reaches that length, not on every bar after.
- A marker is a setup, not a sell signal: the average has turned down after a squeeze, and price has not yet broken below recent lows.
- On the default SPY sample it averaged about six markers per trading day, so judge each marker against the price structure around it.
What it outputs
- Rounding top setup
- Marks the bar where Bollinger width has narrowed for width_drop_n bars in a row while the EMA of close is falling.
When it fires
Fires on the bar where Bollinger width has narrowed for exactly width_drop_n bars in a row and the EMA of close is lower than on the bar before. Each squeeze fires once, at its n-th bar, so a longer one does not repeat. On the default SPY sample it fired 126 times in one month, about six per day.
Settings
- ma_window
- Length of the EMA of close (default 50) whose direction is checked. Shorter reacts to small pullbacks, so the average turns down on minor dips; longer turns down only after larger, slower moves.
- width_window
- Bars in the Bollinger band (default 20) that set band width. Shorter makes width jumpy, so narrowing runs break often and long squeezes are rarer; longer smooths width, so narrowing runs tend to last longer.
- width_drop_n
- Straight bars of narrowing band width needed before the setup fires (default 10). Lower fires on shorter squeezes and so gives more markers. Higher needs a longer squeeze, so markers are fewer; each squeeze fires once, at that length.
Pitfalls
- The shape of the top is not tested: the code does not check for a prior rise, so a falling average inside a downtrend can also fire.
- highs and lows are passed in but never read; only close drives the event, so the range is not checked.
- This is the setup only. The breakdown event in the same module also needs a close below the lowest low of the prior width_window bars, so the setup alone does not mean a sell-off.