OPEN-SOURCE SCRIPT
P3 Candle Grouping

P3 Candle Grouping — draws boxes around candles that trade within a shared range, making consolidation and balance visible at a glance.
A group holds as long as price stays inside the box's high/low. Wicks poking beyond the edge don't break the group — the boundary ratchets out to include them. A group ends only when a candle closes past the boundary by a set tick buffer (default 2 ticks), and that breakout bar seeds the next group. Both the upper and lower boundaries ratchet independently, and the logic runs on confirmed bars only, so boxes don't repaint.
Teal boxes closed bullish, maroon closed bearish, and the yellow box is the current group still forming live.
Settings:
Close must clear boundary by N ticks — how far past the edge a candle must close to end a group. Higher values give fewer, cleaner groups.
Keep last N group boxes — how many completed boxes remain on the chart.
Works on any symbol or timeframe; built with NQ/MNQ in mind. Source is open — feel free to study or build on the grouping logic.
A group holds as long as price stays inside the box's high/low. Wicks poking beyond the edge don't break the group — the boundary ratchets out to include them. A group ends only when a candle closes past the boundary by a set tick buffer (default 2 ticks), and that breakout bar seeds the next group. Both the upper and lower boundaries ratchet independently, and the logic runs on confirmed bars only, so boxes don't repaint.
Teal boxes closed bullish, maroon closed bearish, and the yellow box is the current group still forming live.
Settings:
Close must clear boundary by N ticks — how far past the edge a candle must close to end a group. Higher values give fewer, cleaner groups.
Keep last N group boxes — how many completed boxes remain on the chart.
Works on any symbol or timeframe; built with NQ/MNQ in mind. Source is open — feel free to study or build on the grouping logic.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.