ROC Momentum - Pace and Sensitivity

ROC Momentum - Pace and Sensitivity is an open-source Rate of Change research indicator that separates new price movement from changes in the historical comparison base. It keeps ordinary ROC visible, then examines which observed returns support its current sign and how that sign changes under explicitly defined removal and expiry scenarios.
A rising ROC does not necessarily mean that the newest price rose. An older negative return leaving the comparison window can also lift ROC. This indicator makes that distinction visible without replacing ROC with an opaque composite score.
The tool is intended for descriptive momentum research. It does not produce buy/sell instructions, forecast prices, estimate winning probabilities, execute orders or claim a profitable trading edge.
Getting started
Use standard chart bars and begin with ROC overview. The main line describes the whole-window return; the bottom strip describes confirmed recent-segment pace. The default readout shows ROC, confirmed pace, new-price contribution, expiring-base contribution and their combined change.
Change View to inspect plotted research. Change Readout page to inspect Sensitivity, Cluster stress, Path stress, Return details, Diagnostics or Legend.
Defaults are Close source, N=21 bars for ROC, H=1 bar for observed attribution, K=5 bars for hypothetical expiry, B=3 consecutive moves for block removal, and g=0 log bp/bar for future-path stress. N ranges from 3 to 600. H, K and B are independent inputs, each capped at N; effective values appear in the readout or its tooltip. These are research starting points, not optimized trading parameters.
Default visual language
The primary line is unsmoothed arithmetic ROC: green for positive, pink for negative, and neutral for numerically near-zero net return.
The default bottom strip describes recent-segment pace: green for upward acceleration, cyan for upward easing, pink for downward acceleration, orange for downward easing, and purple for steady or near-zero pace. These states compare recent and middle segments, not the one-bar slope of ROC. Positive whole-window ROC can coexist with Down accelerating because the recent segment may be falling while an earlier gain remains in the window.
The main line can instead follow confirmed pace or use one color. The strip can instead show the replacement driver: blue Price-led, yellow Expiry-led, violet Mixed or no meaningful change, and orange Offsetting. Custom colors are available.
Markers, glow and the omission line are off in the default overview but remain optional. Line widths, fills, contrast, table position, text size, precision and right padding are adjustable. Input and plot values stay out of the title's status line.
Seven display views
ROC overview: ordinary ROC with the selected state strip and compact attribution readout.
Removal sensitivity: actual ROC versus zeroing the largest direction-aligned return. The optional minimum/maximum range covers all individual omissions, not a confidence or prediction interval.
Segment pace: recent, middle and oldest mean log returns per bar. Middle is dashed; oldest is dotted.
Window replacement: actual H-bar ROC change, a blue new-price histogram and a yellow expiring-base line. Contributions add to the observed change in arithmetic percentage points.
Price-held baseline: actual ROC versus keeping the source at its observed H-bars-ago value while its comparison base advances. Optional shading separates these retrospective quantities.
Expiry requirements: average future log-return conditions for preserving today's ROC or reaching zero ROC after K bars. These are conditions at each observation, not forecasts on future bars.
Gap and body: total log return split into previous-Close-to-Open and Open-to-Close contributions. Requires Close and valid positive Open data.
Each plotted view uses one consistent unit. Arithmetic percent, changes in percentage points, log percentage points and log bp/bar are different units. Readout tooltips explain the fields and additional values.
ROC and segment pace
For positive source prices P:
ROC[t] = 100 * (P[t] / P[t-N] - 1).
One-bar log return in basis points:
r[t] = 10000 * log(P[t] / P[t-1]).
The N-bar log return is the sum of N one-bar returns. Divide log basis points by 100 for log percentage points; convert a cumulative log-bp value x to arithmetic percent using 100 * (exp(x/10000) - 1).
The N-bar window is partitioned into three adjacent segments. Extra bars go to newer segments, and each segment is divided by its own bar count. The default pace-change deadband is 5% of mean absolute one-bar movement; the near-zero pace deadband is 2%. Numerical floors also apply. These are adjustable descriptive filters, not statistical tests.
Acceleration is recent-minus-middle pace divided by the distance between segment centers, in log bp/bar squared. Three-segment ordering is available in tooltips, the Data Window and alerts.
A new categorical pace state normally needs two consecutive closed bars with the same raw classification. Persistent changes have one extra confirmation bar; interrupted changes may never confirm. The first valid state initializes immediately. A failed core check resets the filter. Confirmation=1 removes the extra delay. Numerical ROC and pace are never smoothed or shifted by this setting.
Observed price and expiry attribution
The attribution span H measures a change that has already happened. The indicator compares ROC now with ROC H bars ago.
Let:
G = P[t-H] / P[t-N-H]
a = P[t] / P[t-H]
b = P[t-N-H] / P[t-N]
The current gross return is G*a*b. The contributions are:
New price = 50 * G * (a-1) * (1+b)
Expiring base = 50 * G * (b-1) * (1+a)
Their sum equals ROC[t] - ROC[t-H], in arithmetic percentage points. The multiplicative interaction is shared equally between the two factors, equivalent to averaging their marginal contributions over the two application orders. This is an explicit allocation convention, not proof of a unique economic cause or evidence of order flow.
For H=1, the change in the window's log return is the newest return minus the return that just left the window. Larger H compares the multi-bar endpoints directly rather than summing previously allocated one-bar percentages.
Price-led and Expiry-led use absolute contribution shares. The default dominance threshold is 65%. When neither contribution meets it, the label is Mixed. Numerically cancelling changes are labelled Offsetting, while negligible factor changes are labelled No change. Mixed does not mean the two contributions have the same sign. Price/ROC conflict identifies a change in ROC that opposes the H-bar price return, including a numerically flat price return, because the comparison base changed.
For a simple mathematical example, consider prices 100, 98, 99, 101, 101 and N=3. ROC changes from +1.00% to about +3.0612% even though the newest price does not move. New-price contribution is zero; the advancing comparison base explains the increase. This illustrates the mechanism, not a trading result.
Price-held baseline
The baseline is:
Held ROC[t] = 100 * (P[t-H] / P[t-N] - 1).
Actual ROC minus Held ROC measures the recent price effect at the current comparison base. Held ROC minus ROC[t-H] measures the base-only change. These two sequential differences add to the observed H-bar ROC change.
This attribution order differs from the symmetric allocation in Window replacement. The two new-price measures can differ without either being incorrect. They must not be treated as independent confirming signals or interchanged under the same definition. The baseline supplies a visual comparison for the same price-history question, not a new data source.
Endpoint expiry requirements
For a horizon K no greater than N, divide the current log-return window into the oldest K returns that will leave it and the returns that will remain. Call their cumulative log returns Outgoing and Retained.
After K new bars:
Future N-bar log return = Retained + unknown future K-bar log return.
To preserve today's exact ROC, the unknown future cumulative log return must equal Outgoing. To reach zero ROC, it must equal -Retained. Dividing either quantity by K gives the average log bp/bar displayed in Expiry requirements. The readout also converts the cumulative conditions into arithmetic percent and reports ROC under a flat-source assumption.
These are endpoint identities. Equal individual future returns are not required: any future sequence with the same cumulative log return reaches the same endpoint. Above the mathematical zero boundary gives positive ROC; below it gives negative ROC. A negative preserve-ROC requirement is possible when the outgoing block was negative.
The two requirement lines are related algebraically: their difference is the current N-bar log return divided by K. They are not independent signals. Neither is an expected return, recommended holding period, target price or claim about what the market will do.
Single-move and arbitrary removal stress
An omission replaces an observed one-bar log return with zero. It does not delete its timestamp, shorten the window or identify a real economic cause.
The one-move range evaluates every individual omission. The largest direction-aligned omission gives the comparison line. When the current net return is numerically flat, there is no nonzero sign to erase and that directional comparison is unavailable.
The Sensitivity page extends the question to multiple moves. Returns aligned with the current net direction are sorted from largest to smallest. The first cumulative removal that eliminates the current sign gives the minimum number of moves required. Removing opposing returns cannot improve this minimum-cardinality result. Outcomes after exactly two and exactly three aligned omissions are also reported when enough such moves exist.
For example, a minimum count of three means no one- or two-move removal can erase the sign under the script's tolerance, but a targeted three-move removal can. This describes dependence on observed history, not resilience to future losses or a continuation probability.
Contiguous-block stress
The Cluster stress page restricts removal to one uninterrupted block. Opposing moves inside that block are also zeroed. This distinguishes dependence on isolated large moves from dependence on a concentrated run of adjacent moves.
The readout compares the arbitrary minimum count with the shortest consecutive block. Equal shortest blocks select the most recent one. Displayed ages are relative to the selected snapshot; age zero is its newest move.
A separate fixed-B calculation tests all N-B+1 possible B-move blocks and reports the minimum and maximum resulting ROC. A numerically flat current return has no sign-erasure count, but these fixed-block outcomes remain defined.
For example, 80,80,80,-40,-40,-40 and 80,-40,80,-40,80,-40 log bp contain the same moves and have the same current ROC. Both have an arbitrary minimum-erasure count of two, but their shortest contiguous erasures contain two and three moves respectively. These are constructed examples of temporal clustering, not trading-performance evidence.
Flat-source expiry and constant-pace paths
The flat-source expiry test assumes all new future returns are zero. Existing returns leave the window oldest first. It reports the first future bar count at which the current sign becomes zero, numerically near zero or opposite. The original sign can return later. By N bars, all original returns have expired; eventual zero is an identity, not a prediction.
Path stress distinguishes the K-th future close from every intermediate close. Here the assumption is stronger than an endpoint average: the source earns exactly g log bp on EACH of the next K bars.
At future step j:
Hypothetical window log return = Retained[j] + j*g.
For a currently positive sign, the mathematical All-close zero boundary is the maximum of -Retained[j]/j over j=1..K. For a negative sign, it is the minimum. Beyond the unrounded boundary in the appropriate direction, the mathematical sign is maintained at all those closes; equality touches zero at a binding horizon. These conditions do not follow merely from achieving the same final average return with a different path.
The readout gives Zero at K (math), All-close zero boundary, Scenario end ROC, First loss (tolerance), and the weakest signed margin with its future bar number. A positive signed margin means the original mathematical sign; a negative margin means the opposite sign.
The mathematical boundary and numerical classification are deliberately different. The sign-loss test treats a signed margin within 0.000001 log bp of zero as a loss, using the script's normalized numerical comparison. Thus, a very small mathematically positive margin can still count as numerical sign loss. A ~ prefix marks a rounded boundary display, not an exact executable cutoff. Changing text precision never changes the underlying classification.
With observed returns 150,-150,90 log bp and K=3, a hypothetical +10 log bp on every new bar produces positive terminal ROC but loses the original positive sign on the first future bar. The mathematical all-close boundary is +60 log bp/bar. This example demonstrates why endpoint and path conditions are separate questions.
The source and all inputs to these hypothetical calculations are known at the observation. No actual future prices are accessed, and no forecast price path is drawn on future chart bars.
Why the diagnostics add information
Consider three six-move histories in log bp, oldest first:
A: 20,20,20,20,20,20
B: 80,-40,80,-40,80,-40
C: -40,80,-40,80,-40,80
All have current ROC of about +1.2072% and the same three two-bar mean paces. Yet their arbitrary erasure counts are 6,2,2; their first flat-source sign losses are 6,3,6 bars; and their preserve-ROC requirements for K=3 are 20,40,0 log bp/bar.
This demonstrates information that a single current ROC value and those segment averages do not distinguish. It does not mean the complete historical ROC curves are identical, the mathematics is proprietary, or the calculations predict subsequent returns.
Concentration and gap/body details
Equivalent absolute-return bars = (sum of absolute log returns)^2 / sum of squared log returns. Equal nonzero absolute moves give N; one isolated move gives one; a completely flat window is displayed as zero. This is a concentration measure, not an independent sample size, statistical reliability score or probability.
Largest-move share divides the largest absolute log return by the sum of absolute log returns.
For Close, each move also splits into log(Open/previous Close) and log(Close/Open). These gap and body contributions add to total log return. Gap means the bridge between consecutive chart bars, not necessarily overnight. The quantities are log percentage points, not arithmetic percent. Return details retains these supporting diagnostics without adding more lines to the overview.
Historical inspection, realtime behavior and alerts
The table does not follow the crosshair. Enable Inspect a historical timestamp to select the last loaded, closed bar whose CLOSE time is no later than the As-of timestamp. The tooltip identifies that bar and its timezone. A timestamp before eligible history gives an unavailable message, not a later observation.
Inspection changes the table to AS OF, not the historical plots or live alert logic. Removal, cluster and path scans are latest/as-of snapshots, not complete historical series or an event-outcome backtest.
Display closed bars only defaults to on: the forming bar is blank and the table uses a closed observation. Off permits intrabar changes in raw values and snapshots. Pace confirmation and alerts still require bar close. Thus the table can differ from the chart's live price header.
Eight alert conditions cover ROC crossing above/below zero, confirmed pace changing, one-move sensitivity appearing, sign retention under every individual omission returning, three-segment ordering becoming rising/falling, and an expiry-driven price/ROC conflict appearing.
Alerts require valid basic calculations and a confirmed bar. Zero-crossing and tolerance-based sensitivity events have different definitions. Neither inspection nor hypothetical scenarios create forecast alerts. Marker spacing/history settings affect markers, not alert conditions. All events are descriptive, not trade instructions.
Diagnostics and numerical presentation
Core checks cover continuous return identities. Snapshot checks cover alignment and P01-P08: input prices, endpoint/sum agreement, individual omissions, arbitrary minimum removal, chronological expiry, endpoint requirements, contiguous blocks and constant-pace paths. Thirteen deterministic examples run at initialization, including mathematical-boundary versus numerical-tolerance cases.
Basic check failures suppress research lines, research fills, strips, exports and events. Valid ordinary ROC remains separate. Snapshot-specific failures suppress snapshot results and direct the readout to diagnostics; they do not alone invalidate otherwise valid core history. Diagnostic residuals stay visible.
The Data Window has 32 continuous outputs, including status and residuals. Snapshot-only counts are not misrepresented as historical series. Small nonzero table values use extra digits or scientific notation instead of appearing as exact zero.
PASS and CLOSED are internal labels, not TradingView certifications. Arithmetic consistency does not establish predictive power or profitable trading.
Scope and limitations
Use standard chart bars with positive prices. Non-standard charts are disabled. Missing/non-positive observations invalidate affected windows rather than being skipped. Attribution needs N+H valid return intervals; gap/body also needs valid Open values.
Durations count chart bars, not calendar time. For sources other than Close, hypothetical assumptions concern that selected series. Changing source, timeframe, session, history or parameters changes the research question. Related transformations of the same prices are not independent evidence.
Percentage conversion has an extreme-range guard at absolute natural-log magnitude 100; out-of-range percentage results are unavailable, not clipped. Numerical tolerances and rounding matter near boundaries. Closed-bar handling cannot prevent historical data revisions.
There are no external requests, imported libraries, higher-timeframe lookahead, negative plot offsets, pivot backdating, access gates or orders. The script does not automatically detect divergences, optimize strategies or estimate trading performance.
Its contribution is an integrated study of the finite ROC window: incoming movement, expiring history, retained movement and dependence on selected returns. Familiar ROC, pace colors, concentration and gap/body arithmetic support this purpose rather than being presented as inventions. Related mathematics may exist elsewhere; no worldwide uniqueness or trading-performance superiority is claimed.
The source is published under the Mozilla Public License 2.0.
A rising ROC does not necessarily mean that the newest price rose. An older negative return leaving the comparison window can also lift ROC. This indicator makes that distinction visible without replacing ROC with an opaque composite score.
The tool is intended for descriptive momentum research. It does not produce buy/sell instructions, forecast prices, estimate winning probabilities, execute orders or claim a profitable trading edge.
Getting started
Use standard chart bars and begin with ROC overview. The main line describes the whole-window return; the bottom strip describes confirmed recent-segment pace. The default readout shows ROC, confirmed pace, new-price contribution, expiring-base contribution and their combined change.
Change View to inspect plotted research. Change Readout page to inspect Sensitivity, Cluster stress, Path stress, Return details, Diagnostics or Legend.
Defaults are Close source, N=21 bars for ROC, H=1 bar for observed attribution, K=5 bars for hypothetical expiry, B=3 consecutive moves for block removal, and g=0 log bp/bar for future-path stress. N ranges from 3 to 600. H, K and B are independent inputs, each capped at N; effective values appear in the readout or its tooltip. These are research starting points, not optimized trading parameters.
Default visual language
The primary line is unsmoothed arithmetic ROC: green for positive, pink for negative, and neutral for numerically near-zero net return.
The default bottom strip describes recent-segment pace: green for upward acceleration, cyan for upward easing, pink for downward acceleration, orange for downward easing, and purple for steady or near-zero pace. These states compare recent and middle segments, not the one-bar slope of ROC. Positive whole-window ROC can coexist with Down accelerating because the recent segment may be falling while an earlier gain remains in the window.
The main line can instead follow confirmed pace or use one color. The strip can instead show the replacement driver: blue Price-led, yellow Expiry-led, violet Mixed or no meaningful change, and orange Offsetting. Custom colors are available.
Markers, glow and the omission line are off in the default overview but remain optional. Line widths, fills, contrast, table position, text size, precision and right padding are adjustable. Input and plot values stay out of the title's status line.
Seven display views
ROC overview: ordinary ROC with the selected state strip and compact attribution readout.
Removal sensitivity: actual ROC versus zeroing the largest direction-aligned return. The optional minimum/maximum range covers all individual omissions, not a confidence or prediction interval.
Segment pace: recent, middle and oldest mean log returns per bar. Middle is dashed; oldest is dotted.
Window replacement: actual H-bar ROC change, a blue new-price histogram and a yellow expiring-base line. Contributions add to the observed change in arithmetic percentage points.
Price-held baseline: actual ROC versus keeping the source at its observed H-bars-ago value while its comparison base advances. Optional shading separates these retrospective quantities.
Expiry requirements: average future log-return conditions for preserving today's ROC or reaching zero ROC after K bars. These are conditions at each observation, not forecasts on future bars.
Gap and body: total log return split into previous-Close-to-Open and Open-to-Close contributions. Requires Close and valid positive Open data.
Each plotted view uses one consistent unit. Arithmetic percent, changes in percentage points, log percentage points and log bp/bar are different units. Readout tooltips explain the fields and additional values.
ROC and segment pace
For positive source prices P:
ROC[t] = 100 * (P[t] / P[t-N] - 1).
One-bar log return in basis points:
r[t] = 10000 * log(P[t] / P[t-1]).
The N-bar log return is the sum of N one-bar returns. Divide log basis points by 100 for log percentage points; convert a cumulative log-bp value x to arithmetic percent using 100 * (exp(x/10000) - 1).
The N-bar window is partitioned into three adjacent segments. Extra bars go to newer segments, and each segment is divided by its own bar count. The default pace-change deadband is 5% of mean absolute one-bar movement; the near-zero pace deadband is 2%. Numerical floors also apply. These are adjustable descriptive filters, not statistical tests.
Acceleration is recent-minus-middle pace divided by the distance between segment centers, in log bp/bar squared. Three-segment ordering is available in tooltips, the Data Window and alerts.
A new categorical pace state normally needs two consecutive closed bars with the same raw classification. Persistent changes have one extra confirmation bar; interrupted changes may never confirm. The first valid state initializes immediately. A failed core check resets the filter. Confirmation=1 removes the extra delay. Numerical ROC and pace are never smoothed or shifted by this setting.
Observed price and expiry attribution
The attribution span H measures a change that has already happened. The indicator compares ROC now with ROC H bars ago.
Let:
G = P[t-H] / P[t-N-H]
a = P[t] / P[t-H]
b = P[t-N-H] / P[t-N]
The current gross return is G*a*b. The contributions are:
New price = 50 * G * (a-1) * (1+b)
Expiring base = 50 * G * (b-1) * (1+a)
Their sum equals ROC[t] - ROC[t-H], in arithmetic percentage points. The multiplicative interaction is shared equally between the two factors, equivalent to averaging their marginal contributions over the two application orders. This is an explicit allocation convention, not proof of a unique economic cause or evidence of order flow.
For H=1, the change in the window's log return is the newest return minus the return that just left the window. Larger H compares the multi-bar endpoints directly rather than summing previously allocated one-bar percentages.
Price-led and Expiry-led use absolute contribution shares. The default dominance threshold is 65%. When neither contribution meets it, the label is Mixed. Numerically cancelling changes are labelled Offsetting, while negligible factor changes are labelled No change. Mixed does not mean the two contributions have the same sign. Price/ROC conflict identifies a change in ROC that opposes the H-bar price return, including a numerically flat price return, because the comparison base changed.
For a simple mathematical example, consider prices 100, 98, 99, 101, 101 and N=3. ROC changes from +1.00% to about +3.0612% even though the newest price does not move. New-price contribution is zero; the advancing comparison base explains the increase. This illustrates the mechanism, not a trading result.
Price-held baseline
The baseline is:
Held ROC[t] = 100 * (P[t-H] / P[t-N] - 1).
Actual ROC minus Held ROC measures the recent price effect at the current comparison base. Held ROC minus ROC[t-H] measures the base-only change. These two sequential differences add to the observed H-bar ROC change.
This attribution order differs from the symmetric allocation in Window replacement. The two new-price measures can differ without either being incorrect. They must not be treated as independent confirming signals or interchanged under the same definition. The baseline supplies a visual comparison for the same price-history question, not a new data source.
Endpoint expiry requirements
For a horizon K no greater than N, divide the current log-return window into the oldest K returns that will leave it and the returns that will remain. Call their cumulative log returns Outgoing and Retained.
After K new bars:
Future N-bar log return = Retained + unknown future K-bar log return.
To preserve today's exact ROC, the unknown future cumulative log return must equal Outgoing. To reach zero ROC, it must equal -Retained. Dividing either quantity by K gives the average log bp/bar displayed in Expiry requirements. The readout also converts the cumulative conditions into arithmetic percent and reports ROC under a flat-source assumption.
These are endpoint identities. Equal individual future returns are not required: any future sequence with the same cumulative log return reaches the same endpoint. Above the mathematical zero boundary gives positive ROC; below it gives negative ROC. A negative preserve-ROC requirement is possible when the outgoing block was negative.
The two requirement lines are related algebraically: their difference is the current N-bar log return divided by K. They are not independent signals. Neither is an expected return, recommended holding period, target price or claim about what the market will do.
Single-move and arbitrary removal stress
An omission replaces an observed one-bar log return with zero. It does not delete its timestamp, shorten the window or identify a real economic cause.
The one-move range evaluates every individual omission. The largest direction-aligned omission gives the comparison line. When the current net return is numerically flat, there is no nonzero sign to erase and that directional comparison is unavailable.
The Sensitivity page extends the question to multiple moves. Returns aligned with the current net direction are sorted from largest to smallest. The first cumulative removal that eliminates the current sign gives the minimum number of moves required. Removing opposing returns cannot improve this minimum-cardinality result. Outcomes after exactly two and exactly three aligned omissions are also reported when enough such moves exist.
For example, a minimum count of three means no one- or two-move removal can erase the sign under the script's tolerance, but a targeted three-move removal can. This describes dependence on observed history, not resilience to future losses or a continuation probability.
Contiguous-block stress
The Cluster stress page restricts removal to one uninterrupted block. Opposing moves inside that block are also zeroed. This distinguishes dependence on isolated large moves from dependence on a concentrated run of adjacent moves.
The readout compares the arbitrary minimum count with the shortest consecutive block. Equal shortest blocks select the most recent one. Displayed ages are relative to the selected snapshot; age zero is its newest move.
A separate fixed-B calculation tests all N-B+1 possible B-move blocks and reports the minimum and maximum resulting ROC. A numerically flat current return has no sign-erasure count, but these fixed-block outcomes remain defined.
For example, 80,80,80,-40,-40,-40 and 80,-40,80,-40,80,-40 log bp contain the same moves and have the same current ROC. Both have an arbitrary minimum-erasure count of two, but their shortest contiguous erasures contain two and three moves respectively. These are constructed examples of temporal clustering, not trading-performance evidence.
Flat-source expiry and constant-pace paths
The flat-source expiry test assumes all new future returns are zero. Existing returns leave the window oldest first. It reports the first future bar count at which the current sign becomes zero, numerically near zero or opposite. The original sign can return later. By N bars, all original returns have expired; eventual zero is an identity, not a prediction.
Path stress distinguishes the K-th future close from every intermediate close. Here the assumption is stronger than an endpoint average: the source earns exactly g log bp on EACH of the next K bars.
At future step j:
Hypothetical window log return = Retained[j] + j*g.
For a currently positive sign, the mathematical All-close zero boundary is the maximum of -Retained[j]/j over j=1..K. For a negative sign, it is the minimum. Beyond the unrounded boundary in the appropriate direction, the mathematical sign is maintained at all those closes; equality touches zero at a binding horizon. These conditions do not follow merely from achieving the same final average return with a different path.
The readout gives Zero at K (math), All-close zero boundary, Scenario end ROC, First loss (tolerance), and the weakest signed margin with its future bar number. A positive signed margin means the original mathematical sign; a negative margin means the opposite sign.
The mathematical boundary and numerical classification are deliberately different. The sign-loss test treats a signed margin within 0.000001 log bp of zero as a loss, using the script's normalized numerical comparison. Thus, a very small mathematically positive margin can still count as numerical sign loss. A ~ prefix marks a rounded boundary display, not an exact executable cutoff. Changing text precision never changes the underlying classification.
With observed returns 150,-150,90 log bp and K=3, a hypothetical +10 log bp on every new bar produces positive terminal ROC but loses the original positive sign on the first future bar. The mathematical all-close boundary is +60 log bp/bar. This example demonstrates why endpoint and path conditions are separate questions.
The source and all inputs to these hypothetical calculations are known at the observation. No actual future prices are accessed, and no forecast price path is drawn on future chart bars.
Why the diagnostics add information
Consider three six-move histories in log bp, oldest first:
A: 20,20,20,20,20,20
B: 80,-40,80,-40,80,-40
C: -40,80,-40,80,-40,80
All have current ROC of about +1.2072% and the same three two-bar mean paces. Yet their arbitrary erasure counts are 6,2,2; their first flat-source sign losses are 6,3,6 bars; and their preserve-ROC requirements for K=3 are 20,40,0 log bp/bar.
This demonstrates information that a single current ROC value and those segment averages do not distinguish. It does not mean the complete historical ROC curves are identical, the mathematics is proprietary, or the calculations predict subsequent returns.
Concentration and gap/body details
Equivalent absolute-return bars = (sum of absolute log returns)^2 / sum of squared log returns. Equal nonzero absolute moves give N; one isolated move gives one; a completely flat window is displayed as zero. This is a concentration measure, not an independent sample size, statistical reliability score or probability.
Largest-move share divides the largest absolute log return by the sum of absolute log returns.
For Close, each move also splits into log(Open/previous Close) and log(Close/Open). These gap and body contributions add to total log return. Gap means the bridge between consecutive chart bars, not necessarily overnight. The quantities are log percentage points, not arithmetic percent. Return details retains these supporting diagnostics without adding more lines to the overview.
Historical inspection, realtime behavior and alerts
The table does not follow the crosshair. Enable Inspect a historical timestamp to select the last loaded, closed bar whose CLOSE time is no later than the As-of timestamp. The tooltip identifies that bar and its timezone. A timestamp before eligible history gives an unavailable message, not a later observation.
Inspection changes the table to AS OF, not the historical plots or live alert logic. Removal, cluster and path scans are latest/as-of snapshots, not complete historical series or an event-outcome backtest.
Display closed bars only defaults to on: the forming bar is blank and the table uses a closed observation. Off permits intrabar changes in raw values and snapshots. Pace confirmation and alerts still require bar close. Thus the table can differ from the chart's live price header.
Eight alert conditions cover ROC crossing above/below zero, confirmed pace changing, one-move sensitivity appearing, sign retention under every individual omission returning, three-segment ordering becoming rising/falling, and an expiry-driven price/ROC conflict appearing.
Alerts require valid basic calculations and a confirmed bar. Zero-crossing and tolerance-based sensitivity events have different definitions. Neither inspection nor hypothetical scenarios create forecast alerts. Marker spacing/history settings affect markers, not alert conditions. All events are descriptive, not trade instructions.
Diagnostics and numerical presentation
Core checks cover continuous return identities. Snapshot checks cover alignment and P01-P08: input prices, endpoint/sum agreement, individual omissions, arbitrary minimum removal, chronological expiry, endpoint requirements, contiguous blocks and constant-pace paths. Thirteen deterministic examples run at initialization, including mathematical-boundary versus numerical-tolerance cases.
Basic check failures suppress research lines, research fills, strips, exports and events. Valid ordinary ROC remains separate. Snapshot-specific failures suppress snapshot results and direct the readout to diagnostics; they do not alone invalidate otherwise valid core history. Diagnostic residuals stay visible.
The Data Window has 32 continuous outputs, including status and residuals. Snapshot-only counts are not misrepresented as historical series. Small nonzero table values use extra digits or scientific notation instead of appearing as exact zero.
PASS and CLOSED are internal labels, not TradingView certifications. Arithmetic consistency does not establish predictive power or profitable trading.
Scope and limitations
Use standard chart bars with positive prices. Non-standard charts are disabled. Missing/non-positive observations invalidate affected windows rather than being skipped. Attribution needs N+H valid return intervals; gap/body also needs valid Open values.
Durations count chart bars, not calendar time. For sources other than Close, hypothetical assumptions concern that selected series. Changing source, timeframe, session, history or parameters changes the research question. Related transformations of the same prices are not independent evidence.
Percentage conversion has an extreme-range guard at absolute natural-log magnitude 100; out-of-range percentage results are unavailable, not clipped. Numerical tolerances and rounding matter near boundaries. Closed-bar handling cannot prevent historical data revisions.
There are no external requests, imported libraries, higher-timeframe lookahead, negative plot offsets, pivot backdating, access gates or orders. The script does not automatically detect divergences, optimize strategies or estimate trading performance.
Its contribution is an integrated study of the finite ROC window: incoming movement, expiring history, retained movement and dependence on selected returns. Familiar ROC, pace colors, concentration and gap/body arithmetic support this purpose rather than being presented as inventions. Related mathematics may exist elsewhere; no worldwide uniqueness or trading-performance superiority is claimed.
The source is published under the Mozilla Public License 2.0.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.