OPEN-SOURCE SCRIPT
Body Close Continuity & failure Backtesting @MaxMaserati

This indicator, is a highly advanced institutional-grade tool designed to track the "lifespan" of a trend based on Body Close (BC) sequences.
Unlike basic indicators that just show direction, this script analyzes the structural integrity of a trend by monitoring how many candles continue the move before a "Touch" (retest) or a "Break" (failure) occurs.
The Continuity & Failure Stats indicator tracks sequences of Bullish Body Closes (BuBC) and Bearish Body Closes (BeBC). It measures three critical phases: Building (pure momentum), Touching (price retesting the low/high of the sequence), and Resumption (price continuing the trend after a retest). It provides a statistical distribution of how long these "buildings" typically last before failing, allowing traders to know exactly when a trend is overextended.
This comprehensive analysis blends the statistical breakdown of the Continuity & Failure Stats indicator to provide a deep understanding of the structural momentum for the S&P 500 E-mini (ES1!) on a 4-hour timeframe.

1. Extensive Table Breakdown
A. Building Distribution (Left Table): The Fatigue Gauge
This table acts as a histogram of momentum, tracking the "Building Count"—the number of consecutive candles closing in a trend without price returning to its origin.
Count Column: Represents the streak length (e.g., 1, 2, or 3 candles).
Touch Column: Shows how many times a streak was interrupted by a retest ("touch") but remained structurally intact.
Break Column: Counts total structural failures where price closed beyond the sequence's anchor.
Data Insight: For BuBC, 92 sequences reached Count 1, but only 28 remained by Count 4. This reveals a steep momentum decay after the 3rd candle, establishing a "Statistical Wall" where only 2 sequences in history reached a count of 9.
B. MMM Summary Stats (Top Right): The Mathematical DNA
This table provides the "Expected Value" and behavior of a trend over the lookback period.
Avg Building (2.39 for BuBC): On average, a bullish move lasts ~2.4 candles of pure momentum before a retest or reversal occurs.
Avg Touches (0.8): This low number indicates "clean" trends that rarely wobble back to retest levels multiple times before reaching a conclusion.
Avg R Cycles (0.55): This suggests that once a bullish trend is interrupted, it only successfully resumes its momentum about half the time.
Max R Count (1): Typically, once a trend is "touched," it only manages one more push before failing.
C. Multi-Timeframe (MTF) Quick Stats (Bottom Right): Trend Weight
This compares the 4H chart against other layers of the market to identify "global" alignment.
Sample Comparison: There are 3,594 tracked BuBC sequences on the 4H compared to only 142 on the Weekly chart.
Fractal Law: The Avg Building (2.4) is consistent across several timeframes, implying that the "Rule of Three" (momentum fading after 3 candles) is a fractal characteristic of this asset.
2. Table Comparison: Synthesizing the Data
To trade effectively, you must compare Distribution (timing) against Summary Stats (averages):
Continuity vs. Failure: The Summary Stats show an average building of 2.39. When checking the Distribution table at Count 2, the "Break" count (58) is already high relative to the "Total". This confirms that the risk of failure increases exponentially the moment you exceed the average.
Momentum vs. Mean Reversion: Distribution tells you when a trend is "tired". If the 4H is at a "Building Count 4" (statistically overextended) while the Weekly chart is at "Building Count 1" (fresh momentum), you may choose to prioritize the higher timeframe's strength despite the local overextension.
3. Strategic Summary & Application
This indicator proves that market momentum follows a predictable "Building" cycle rather than an infinite streak.
The "Rule of Three" for ES1! 4H:
The Entry Zone (Momentum Start): The most profitable entries occur at Building Count 1. Statistically, you have a high probability of reaching a count of 2 or 3.
The Exit Zone (Momentum Limit): Take profits or tighten stops at Count 3. The data shows the sample size drops by nearly 50% between Count 3 and Count 4.
The "Touch" Rule (Retest Reliability): If price returns to the sequence low (a "Touch"), do not expect a massive continuation. The Max R Count of 1 tells us that resumptions are usually short-lived.
Danger Zone: Entering at Building Count 4 or higher is statistically dangerous, as the "Break" probability significantly outweighs the "Touch" or continuation probability.
Unlike basic indicators that just show direction, this script analyzes the structural integrity of a trend by monitoring how many candles continue the move before a "Touch" (retest) or a "Break" (failure) occurs.
The Continuity & Failure Stats indicator tracks sequences of Bullish Body Closes (BuBC) and Bearish Body Closes (BeBC). It measures three critical phases: Building (pure momentum), Touching (price retesting the low/high of the sequence), and Resumption (price continuing the trend after a retest). It provides a statistical distribution of how long these "buildings" typically last before failing, allowing traders to know exactly when a trend is overextended.
This comprehensive analysis blends the statistical breakdown of the Continuity & Failure Stats indicator to provide a deep understanding of the structural momentum for the S&P 500 E-mini (ES1!) on a 4-hour timeframe.
1. Extensive Table Breakdown
A. Building Distribution (Left Table): The Fatigue Gauge
This table acts as a histogram of momentum, tracking the "Building Count"—the number of consecutive candles closing in a trend without price returning to its origin.
Count Column: Represents the streak length (e.g., 1, 2, or 3 candles).
Touch Column: Shows how many times a streak was interrupted by a retest ("touch") but remained structurally intact.
Break Column: Counts total structural failures where price closed beyond the sequence's anchor.
Data Insight: For BuBC, 92 sequences reached Count 1, but only 28 remained by Count 4. This reveals a steep momentum decay after the 3rd candle, establishing a "Statistical Wall" where only 2 sequences in history reached a count of 9.
B. MMM Summary Stats (Top Right): The Mathematical DNA
This table provides the "Expected Value" and behavior of a trend over the lookback period.
Avg Building (2.39 for BuBC): On average, a bullish move lasts ~2.4 candles of pure momentum before a retest or reversal occurs.
Avg Touches (0.8): This low number indicates "clean" trends that rarely wobble back to retest levels multiple times before reaching a conclusion.
Avg R Cycles (0.55): This suggests that once a bullish trend is interrupted, it only successfully resumes its momentum about half the time.
Max R Count (1): Typically, once a trend is "touched," it only manages one more push before failing.
C. Multi-Timeframe (MTF) Quick Stats (Bottom Right): Trend Weight
This compares the 4H chart against other layers of the market to identify "global" alignment.
Sample Comparison: There are 3,594 tracked BuBC sequences on the 4H compared to only 142 on the Weekly chart.
Fractal Law: The Avg Building (2.4) is consistent across several timeframes, implying that the "Rule of Three" (momentum fading after 3 candles) is a fractal characteristic of this asset.
2. Table Comparison: Synthesizing the Data
To trade effectively, you must compare Distribution (timing) against Summary Stats (averages):
Continuity vs. Failure: The Summary Stats show an average building of 2.39. When checking the Distribution table at Count 2, the "Break" count (58) is already high relative to the "Total". This confirms that the risk of failure increases exponentially the moment you exceed the average.
Momentum vs. Mean Reversion: Distribution tells you when a trend is "tired". If the 4H is at a "Building Count 4" (statistically overextended) while the Weekly chart is at "Building Count 1" (fresh momentum), you may choose to prioritize the higher timeframe's strength despite the local overextension.
3. Strategic Summary & Application
This indicator proves that market momentum follows a predictable "Building" cycle rather than an infinite streak.
The "Rule of Three" for ES1! 4H:
The Entry Zone (Momentum Start): The most profitable entries occur at Building Count 1. Statistically, you have a high probability of reaching a count of 2 or 3.
The Exit Zone (Momentum Limit): Take profits or tighten stops at Count 3. The data shows the sample size drops by nearly 50% between Count 3 and Count 4.
The "Touch" Rule (Retest Reliability): If price returns to the sequence low (a "Touch"), do not expect a massive continuation. The Max R Count of 1 tells us that resumptions are usually short-lived.
Danger Zone: Entering at Building Count 4 or higher is statistically dangerous, as the "Break" probability significantly outweighs the "Touch" or continuation probability.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
MMM : No body close (PO4), No Trade.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
MMM : No body close (PO4), No Trade.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。