OPEN-SOURCE SCRIPT
MA RespectRatio

RespectRatio
A Structural Moving Average Quality Indicator
What is RespectRatio
RespectRatio is a statistical indicator designed to evaluate *how reliably a stock respects a specific moving average over time.
Instead of asking “Did price touch the MA?”, it answers a more meaningful question:
Does this moving average actually function as support for this stock consistently and structurally?
The indicator focuses on *historical behavior, not short-term signals, and is intended to support buy / hold / reduce decisions rather than precise trade timing.
Why RespectRatio Exists
Many stocks frequently touch moving averages, but only some of them:
Rebound cleanly
Hold above the average
Do so repeatedly over long periods
RespectRatio was built to separate real support from visual noise.
Core Concept
RespectRatio treats every interaction between price and the moving average as a measurable event.
Each event ends in one of two outcomes:
• Bounce — price respects the moving average
• Break — price fails and breaks below it
Over time, these outcomes form a probability profile of how the stock behaves around that average.
How an Event Starts
An event begins when price meaningfully interacts with the moving average, either by:
• Entering a volatility-adjusted proximity zone around the MA, or
• Crossing below the MA (including gap-downs)
The proximity zone is adaptive and defined as:
k = ATR% × kMultiplier
This keeps the definition of “close enough” consistent across assets and volatility regimes.
Event Outcomes
Bounce (Respect)
An event is classified as a Bounce when price:
• Moves back above the moving average
• Clears a minimal buffer above it
• *Maintains that position for a defined number of sessions.
This confirms that the moving average acted as real support not a temporary pause.
Break (Failure)
An event becomes a Break when price:
• Remains below the moving average for too long, or
• Falls significantly below it and fails to reclaim it within a short window
A Break signals structural weakness at that average.
Noise Control
To avoid statistical distortion:
• Only one outcome per event is recorded
• A cooldown period prevents immediate re-counting of the same struggle
• Each event is counted once, regardless of intraday noise
This ensures clean, independent data points.
The Final Metric
The indicator produces a single core metric:
RespectRatio = Bounces / (Bounces + Breaks)
Calculated over a rolling historical window.
How to Interpret RespectRatio
• High RespectRatio
The moving average has historically acted as reliable support
→ suitable for accumulation or holding strategies
• Low RespectRatio
The moving average is frequently violated
→ caution when relying on it as support
RespectRatio does not predict future price, but measures structural trustworthiness.
What RespectRatio Is Not
• Not a buy/sell signal generator
• Not a trend-following indicator
• Not a momentum oscillator
It is a contextual filter* that improves decision quality.
Typical Use Cases
• Evaluating whether a stock deserves to be bought near a long-term MA
• Comparing multiple stocks using the same moving average
• Filtering candidates before applying other strategies
• Long-term portfolio decision support
One-Sentence Summary
RespectRatio quantifies how often the market actually respects a moving average — turning a visual assumption into measurable probability.*
A Structural Moving Average Quality Indicator
What is RespectRatio
RespectRatio is a statistical indicator designed to evaluate *how reliably a stock respects a specific moving average over time.
Instead of asking “Did price touch the MA?”, it answers a more meaningful question:
Does this moving average actually function as support for this stock consistently and structurally?
The indicator focuses on *historical behavior, not short-term signals, and is intended to support buy / hold / reduce decisions rather than precise trade timing.
Why RespectRatio Exists
Many stocks frequently touch moving averages, but only some of them:
Rebound cleanly
Hold above the average
Do so repeatedly over long periods
RespectRatio was built to separate real support from visual noise.
Core Concept
RespectRatio treats every interaction between price and the moving average as a measurable event.
Each event ends in one of two outcomes:
• Bounce — price respects the moving average
• Break — price fails and breaks below it
Over time, these outcomes form a probability profile of how the stock behaves around that average.
How an Event Starts
An event begins when price meaningfully interacts with the moving average, either by:
• Entering a volatility-adjusted proximity zone around the MA, or
• Crossing below the MA (including gap-downs)
The proximity zone is adaptive and defined as:
k = ATR% × kMultiplier
This keeps the definition of “close enough” consistent across assets and volatility regimes.
Event Outcomes
Bounce (Respect)
An event is classified as a Bounce when price:
• Moves back above the moving average
• Clears a minimal buffer above it
• *Maintains that position for a defined number of sessions.
This confirms that the moving average acted as real support not a temporary pause.
Break (Failure)
An event becomes a Break when price:
• Remains below the moving average for too long, or
• Falls significantly below it and fails to reclaim it within a short window
A Break signals structural weakness at that average.
Noise Control
To avoid statistical distortion:
• Only one outcome per event is recorded
• A cooldown period prevents immediate re-counting of the same struggle
• Each event is counted once, regardless of intraday noise
This ensures clean, independent data points.
The Final Metric
The indicator produces a single core metric:
RespectRatio = Bounces / (Bounces + Breaks)
Calculated over a rolling historical window.
How to Interpret RespectRatio
• High RespectRatio
The moving average has historically acted as reliable support
→ suitable for accumulation or holding strategies
• Low RespectRatio
The moving average is frequently violated
→ caution when relying on it as support
RespectRatio does not predict future price, but measures structural trustworthiness.
What RespectRatio Is Not
• Not a buy/sell signal generator
• Not a trend-following indicator
• Not a momentum oscillator
It is a contextual filter* that improves decision quality.
Typical Use Cases
• Evaluating whether a stock deserves to be bought near a long-term MA
• Comparing multiple stocks using the same moving average
• Filtering candidates before applying other strategies
• Long-term portfolio decision support
One-Sentence Summary
RespectRatio quantifies how often the market actually respects a moving average — turning a visual assumption into measurable probability.*
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.