OPEN-SOURCE SCRIPT

Return Dispersion Matrix [The Quant Science]

1 282
Introduction
The Return Dispersion Matrix is a quantitative analysis tool that maps the temporal dependence of returns. In technical terms, performs a two-dimensional, 1-lag autocorrelation analysis, measuring the relationship and relative frequency between the return of the previous session (Yesterday) and that of the current session (Today) within specific volatility ranges.

It answers the key questions:
💭 🔑 “When a candle closes in the green or red, what is the most common range of returns?”
💭 🔑 “When the price did X yesterday, what does it probably do today?”

What does this indicator do?
1. Automatically calculate the probability of future returns for a given range of values and display the result in the right-hand column.
스냅샷

2. Instantly identify the market trend using the quadrants. Calculates the quadrant with the highest number of points and highlights it by lighting it up.
스냅샷

🟢 Q1
  • A green candle followed by another green candle
  • High concentration of points indicates that positive days tend to generate immediate additional momentum
  • Suitable for trend-following and bullish breakout strategies

스냅샷

🟢 Q2
  • A red candle followed by a green candle
  • Heavy trading volume indicates a “resilient” market: buyers step in immediately when prices fall (“buy the dip”)
  • Suitable for accumulation strategies on pullbacks

스냅샷

🔴 Q3
  • A red candle followed by another red candle
  • Indicates that sales generate further sales without immediate support
  • Sign of underlying weakness or persistent downtrends

스냅샷

🔴 Q4
  • A green candle followed by a red candle
  • There are many indications that rallies are short-lived and lead to rapid profit-taking in the Suitable for “sell the rally” strategies

스냅샷

The horizontal X-axis represents the return of the previous candle (t-1), while the vertical Y-axis shows the return of the current candle (t). This allows you to visually determine whether a positive or negative day tends to be followed by one of the same sign (persistence) or the opposite sign (mean reversion).
스냅샷
X-axis
  • To the right of 0: previous candle closed in positive territory (+)
  • To the left of 0: previous candle closed in negative territory (-)

Y-axis
  • Above 0: current candle is closing / has closed in positive territory (+)
  • Below 0: current candle is closing / has closed in negative territory (-)


3. Automatically calculates volatility bands. It identifies the maximum range observed during the analysis period and divides the positive values into bands. These values are displayed in the left column in white.
스냅샷

4. Automatically calculates frequency clusters. The density and transparency of the points immediately reveal where most sessions are concentrated and which events represent anomalies or extreme outliers.
스냅샷

Uses
Identifying the Market Regime
Observing the concentration of points reveals the prevailing nature of the asset:
  • Q1 / Q3 Prevalence (Trend / Inertia): The market tends toward continuation. The best strategy is to buy on breakouts or sell on support breaks.
  • Prevalence of Q2 / Q4 (Mean Reversion): Buying at highs is statistically a losing strategy.


Assessment of Asymmetry and Risk Management (Fat Tails)
By comparing the vertical extent of the points on the positive and negative sides:
If, on the negative side (Q3 / Q4), the points frequently reach the extreme ranges (e.g., -L4 or -L5), while on the positive side they stop at +L2, the asset exhibits asymmetric downside volatility (crash risk). Essential for the correct calculation of position sizing and for the strategic placement of stop-loss orders.

Operational Execution Filter (Probabilistic Edge)
The tool acts as a statistical validator before entering the market:
Example: A trader wants to go long on an asset. The matrix shows that, under current conditions, Quadrant Q2 has a frequency of 45% (high probability that a red day will be followed by a green day). Instead of buying during the positive candle, the trader waits for a negative session to close before placing a buy order at the next opening, thereby maximizing expected return.

Settings
Traders can easily adjust the indicator's parameters using the user interface.
  1. Data Points Visualization: adjust the number of points within the matrix
  2. Matrix Offset: move the table to the right on the graph
  3. Levels Color: set the indicator colors
  4. Highlight Dominant Quadrant: apply automatic calculation of the winning quadrant

스냅샷

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.