OPEN-SOURCE SCRIPT
Candle Streak Statistics

Candle Streak Statistics
What it does
This indicator counts every consecutive run of up-candles and down-candles in the chart's full history, then tells you how unusual the current run is compared to all the runs that came before it. Think of it as a "thermometer" that shows whether the market is in a perfectly normal streak or in territory it rarely visits.
Why it exists
I often ask myself: "Eight green candles in a row. Is that a lot?"
What you'll see
A compact stats table (position and size are configurable) showing, separately for up-streaks and down-streaks:
n: how many completed streaks were observed
Current run: length of the streak in progress
Pct rank: where the current run sits in the historical distribution (0% = shorter than everything, 100% = longest ever)
P(+1 more): historical probability that a streak which reached the current length extended by at least one more bar
Mean, Stdev, Median: central-tendency stats
p75 / p90 / p95: upper-percentile streak lengths
Mode: most common streak length (usually 1)
Optionally, a floating label above the last candle draws a 10-segment █/░ bar (the "thermometer" — for an at-a-glance read on rarity.)
How to read it
Pct rank ≥ 90% with low P(+1 more) → the current streak is in the rare-air zone and historically rarely extends further. Mean-reversion is statistically likely.
Pct rank mid-range with P(+1 more) ≥ 50% → nothing unusual; trend has room to continue.
Up vs. Down asymmetry → on equities, up-streaks typically have longer tails than down-streaks. Watching this gap shift can flag regime changes.
Design choices worth knowing
Doji handling: by default, exactly equal close == open bars are ignored (they don't break a streak). Adjustable via a tolerance input if you want to treat tiny-bodied candles the same way.
The live unfinished streak is excluded from the distribution by default. Including a still-in-progress run biases percentiles downward (it's censored data). A toggle lets you override.
Sample-size warning: if a direction has fewer than N completed streaks (default 20), its column gets a ⚠ marker. Don't trust statistics built on too little data.
Built on confirmed bars only. The distribution doesn't churn on every realtime tick.
Customization
Every visible element has a clearly labeled input: table position (9 anchor points), text size, all colors (text, neutral cell, up/down highlight, header), highlight transparency, and thermometer label colors. Defaults are tuned for light-themed charts.
Alerts
"Up streak ≥ p90": current up-run has entered the top 10% of history
"Down streak ≥ p90": current down-run has entered the top 10% of history
Best paired with
Any trend-following or stop-loss indicator. The combination of "my trailing stop says still hold" + "this streak is at p95 with a 15% continuation probability" is more informative than either signal alone. Use it as a sanity check on overextended moves.
Limitations
Streak-length distributions are roughly geometric. The mode is almost always 1, so I don't even know why I put it there. Don't lean on it.
Small samples (intraday timeframes on short chart histories) produce noisy upper-percentile estimates. Watch the n column.
Continuation probability is purely historical; it makes no claim about regime stability going forward. Statistics describe the past.
What it does
This indicator counts every consecutive run of up-candles and down-candles in the chart's full history, then tells you how unusual the current run is compared to all the runs that came before it. Think of it as a "thermometer" that shows whether the market is in a perfectly normal streak or in territory it rarely visits.
Why it exists
I often ask myself: "Eight green candles in a row. Is that a lot?"
What you'll see
A compact stats table (position and size are configurable) showing, separately for up-streaks and down-streaks:
n: how many completed streaks were observed
Current run: length of the streak in progress
Pct rank: where the current run sits in the historical distribution (0% = shorter than everything, 100% = longest ever)
P(+1 more): historical probability that a streak which reached the current length extended by at least one more bar
Mean, Stdev, Median: central-tendency stats
p75 / p90 / p95: upper-percentile streak lengths
Mode: most common streak length (usually 1)
Optionally, a floating label above the last candle draws a 10-segment █/░ bar (the "thermometer" — for an at-a-glance read on rarity.)
How to read it
Pct rank ≥ 90% with low P(+1 more) → the current streak is in the rare-air zone and historically rarely extends further. Mean-reversion is statistically likely.
Pct rank mid-range with P(+1 more) ≥ 50% → nothing unusual; trend has room to continue.
Up vs. Down asymmetry → on equities, up-streaks typically have longer tails than down-streaks. Watching this gap shift can flag regime changes.
Design choices worth knowing
Doji handling: by default, exactly equal close == open bars are ignored (they don't break a streak). Adjustable via a tolerance input if you want to treat tiny-bodied candles the same way.
The live unfinished streak is excluded from the distribution by default. Including a still-in-progress run biases percentiles downward (it's censored data). A toggle lets you override.
Sample-size warning: if a direction has fewer than N completed streaks (default 20), its column gets a ⚠ marker. Don't trust statistics built on too little data.
Built on confirmed bars only. The distribution doesn't churn on every realtime tick.
Customization
Every visible element has a clearly labeled input: table position (9 anchor points), text size, all colors (text, neutral cell, up/down highlight, header), highlight transparency, and thermometer label colors. Defaults are tuned for light-themed charts.
Alerts
"Up streak ≥ p90": current up-run has entered the top 10% of history
"Down streak ≥ p90": current down-run has entered the top 10% of history
Best paired with
Any trend-following or stop-loss indicator. The combination of "my trailing stop says still hold" + "this streak is at p95 with a 15% continuation probability" is more informative than either signal alone. Use it as a sanity check on overextended moves.
Limitations
Streak-length distributions are roughly geometric. The mode is almost always 1, so I don't even know why I put it there. Don't lean on it.
Small samples (intraday timeframes on short chart histories) produce noisy upper-percentile estimates. Watch the n column.
Continuation probability is purely historical; it makes no claim about regime stability going forward. Statistics describe the past.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.