OPEN-SOURCE SCRIPT
Streak statistics

After four red bars, what actually happens? Your chart already knows.
Description
Counts every run of consecutive up closes and consecutive down closes on the loaded chart and reports, for each exact streak length, how often that streak extended by one more bar. The instrument's own base rate of up and down closes is shown alongside, so every continuation frequency can be read against what an ordinary bar does rather than against an imagined 50%.
How it calculates
Direction is close against prior close. Each time a streak reaches a length, that length's denominator increments; each time it extends by one more bar, the numerator increments. The figure at length three therefore answers exactly: of the streaks that reached three, what share became four. The final row pools every resolved opportunity at or beyond the configured cap.
Right-censoring is handled correctly. A streak enters a denominator only when its next bar is known, so the unfinished streak sitting at the chart edge is never silently counted as a failed continuation. Reset boundaries censor the preceding streak rather than treating the boundary or the overnight gap as a failure. A flat close terminates a streak without extending either side.
The sample is a precise rolling number of observed comparisons rather than an unknown quantity determined only by your chart plan's history allowance, and the date range actually in the window is reported in the header tooltip. The window is rebuilt when the sample changes, once per bar close, not on every price tick.
Each continuation rate carries its sample size and an optional 95% Wilson interval. A separate base-rate-centered stabilized estimate is available and is never substituted for the empirical frequency; both are shown.
How to read it
The first row shows the current streak and, when a resolved sample exists for that state, its historical continuation, opposite, and flat shares plus the lift against base. The base row shows the share of all observed moves that were up, down, and flat. Each length row shows the continuation share, the sample size, the interval, and the stabilized estimate, per direction, with the lift in percentage points beside it.
Emphasis marks a cell that is both materially different from its base rate and interval-separated from it. It marks a departure in either direction; the sign is carried by the lift column, never by colour alone.
Repainting
Closed bars do not repaint. The live bar never enters the sample.
Timeframe requirements
Any intraday timeframe when a reset mode is active. Calendar-day reset and custom-session reset both require an intraday chart, because on daily or higher a calendar-day reset would exclude every bar. Set reset mode to Never to run on daily and above.
Originality and attribution
Run counting is elementary probability. What is original here is the treatment: continuation frequency by exact streak length and direction, conditioned so each length's denominator is the number of streaks that actually reached it, correct right-censoring at the chart edge and at reset boundaries, a bounded rolling sample in observed moves rather than in chart history, and base rate, interval, and sample size shown rather than implied. This is not derived from and does not reuse code from any existing published script.
Honest limitations
Descriptive frequencies are not forecasts, signals, or proof of an edge.
Serial dependence means the Wilson intervals are descriptive uncertainty bands, not a complete market-microstructure hypothesis test.
Looking across many rows creates multiple-comparison risk. Emphasis requires both interval separation and a minimum effect you set, but that does not eliminate data-mining risk.
Rare long streaks stay rare. Stabilization reduces visual overreaction; it cannot manufacture information that is not in the sample.
Close-to-close direction counts overnight gaps unless a reset mode is on.
The rolling window is measured in observed comparisons, not clock time.
Description
Counts every run of consecutive up closes and consecutive down closes on the loaded chart and reports, for each exact streak length, how often that streak extended by one more bar. The instrument's own base rate of up and down closes is shown alongside, so every continuation frequency can be read against what an ordinary bar does rather than against an imagined 50%.
How it calculates
Direction is close against prior close. Each time a streak reaches a length, that length's denominator increments; each time it extends by one more bar, the numerator increments. The figure at length three therefore answers exactly: of the streaks that reached three, what share became four. The final row pools every resolved opportunity at or beyond the configured cap.
Right-censoring is handled correctly. A streak enters a denominator only when its next bar is known, so the unfinished streak sitting at the chart edge is never silently counted as a failed continuation. Reset boundaries censor the preceding streak rather than treating the boundary or the overnight gap as a failure. A flat close terminates a streak without extending either side.
The sample is a precise rolling number of observed comparisons rather than an unknown quantity determined only by your chart plan's history allowance, and the date range actually in the window is reported in the header tooltip. The window is rebuilt when the sample changes, once per bar close, not on every price tick.
Each continuation rate carries its sample size and an optional 95% Wilson interval. A separate base-rate-centered stabilized estimate is available and is never substituted for the empirical frequency; both are shown.
How to read it
The first row shows the current streak and, when a resolved sample exists for that state, its historical continuation, opposite, and flat shares plus the lift against base. The base row shows the share of all observed moves that were up, down, and flat. Each length row shows the continuation share, the sample size, the interval, and the stabilized estimate, per direction, with the lift in percentage points beside it.
Emphasis marks a cell that is both materially different from its base rate and interval-separated from it. It marks a departure in either direction; the sign is carried by the lift column, never by colour alone.
Repainting
Closed bars do not repaint. The live bar never enters the sample.
Timeframe requirements
Any intraday timeframe when a reset mode is active. Calendar-day reset and custom-session reset both require an intraday chart, because on daily or higher a calendar-day reset would exclude every bar. Set reset mode to Never to run on daily and above.
Originality and attribution
Run counting is elementary probability. What is original here is the treatment: continuation frequency by exact streak length and direction, conditioned so each length's denominator is the number of streaks that actually reached it, correct right-censoring at the chart edge and at reset boundaries, a bounded rolling sample in observed moves rather than in chart history, and base rate, interval, and sample size shown rather than implied. This is not derived from and does not reuse code from any existing published script.
Honest limitations
Descriptive frequencies are not forecasts, signals, or proof of an edge.
Serial dependence means the Wilson intervals are descriptive uncertainty bands, not a complete market-microstructure hypothesis test.
Looking across many rows creates multiple-comparison risk. Emphasis requires both interval separation and a minimum effect you set, but that does not eliminate data-mining risk.
Rare long streaks stay rare. Stabilization reduces visual overreaction; it cannot manufacture information that is not in the sample.
Close-to-close direction counts overnight gaps unless a reset mode is on.
The rolling window is measured in observed comparisons, not clock time.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。