Consolidation and Breakout: a mother bar's range, the inside bars that keep it
alive, and the bar that finally leaves it.
This one is a state machine rather than a formula. A single index is carried
from bar to bar: the bar whose high and low currently define the range. Every
later bar whose body (open to close, wicks ignored) sits inside that range
extends the consolidation, and the first body to escape it becomes the new
mother.
The two reads of that index straddle the reassignment, and that ordering is
the study:
the breakout tests read the range as it stood before this bar could
claim it, which is what makes a breakout a statement about the old range;
the plotted range and the inside-bar tint read it after, so a bar that
breaks out is already the new mother and is correctly left untinted.
One bar therefore both fires a marker and opens the next consolidation.
Collapsing the two into one read shifts every signal by a bar, which still
looks plausible on a chart, so tests/study-consolidation.test.ts pins the
breaking bar itself.
Bar 1 is excluded from the inside test by the definition: with the carried
index seeded at 0, bar 1 would otherwise be measured against a range that has
had no chance to be broken.
Not reproduced: the thickness control the published definition puts on the two
range lines. style.lineWidth is static here and no settings key stands
behind it, so the control would move nothing. The lines are fixed at 2.
Consolidation and Breakout: a mother bar's range, the inside bars that keep it alive, and the bar that finally leaves it.
This one is a state machine rather than a formula. A single index is carried from bar to bar: the bar whose high and low currently define the range. Every later bar whose body (open to close, wicks ignored) sits inside that range extends the consolidation, and the first body to escape it becomes the new mother.
The two reads of that index straddle the reassignment, and that ordering is the study:
tests/study-consolidation.test.tspins the breaking bar itself.Bar 1 is excluded from the inside test by the definition: with the carried index seeded at 0, bar 1 would otherwise be measured against a range that has had no chance to be broken.
Not reproduced: the thickness control the published definition puts on the two range lines.
style.lineWidthis static here and no settings key stands behind it, so the control would move nothing. The lines are fixed at 2.