# AlphaBeta Dashboard Pro (Indicator)

## 1. Summary

**AlphaBeta Dashboard Pro** is an institutional-grade multi-asset scanner panel designed to monitor and visualize rolling Alpha (excess risk-adjusted return) and Beta (systematic market sensitivity) in real-time. It maps out a customized list of symbols or the entire Market Watch inside a highly compact, 3-column separate chart overlay table, allowing traders to instantly spot structural market leaders and hedge-vehicles.

Featuring **Click-to-Switch** interactive chart technology, the dashboard allows traders to click on any symbol button in the table to instantly change the active chart's symbol, dramatically accelerating the workflow of quantitative scanning.

---

## 2. Mathematical Foundations and Calculation Logic

The dashboard leverages the core `CMathStatisticsCalculator` engine to perform rolling Capital Asset Pricing Model (CAPM) analysis on any asset relative to its corresponding benchmark on the target timeframe (`InpTimeframe`).

### A. Window-Aligned Logarithmic Returns

To achieve 100% mathematical alignment with the standalone indicators, the dashboard copies exactly $W$ (`InpLookback`) closing prices. This generates a stationary log-return series of size $W - 1$ for both the Asset ($R_A$) and the Benchmark ($R_B$):

$$R_{A,t} = \ln\left(\frac{P_{A,t}}{P_{A,t-1}}\right)$$

$$R_{B,t} = \ln\left(\frac{P_{B,t}}{P_{B,t-1}}\right)$$

### B. Rolling Beta Calculation

Beta measures the systematic risk of the asset, demonstrating its volatility amplification relative to the benchmark:

$$\beta = \frac{\text{Covariance}(R_A, R_B)}{\text{Variance}(R_B)}$$

### C. Rolling Alpha Calculation

Alpha measures the risk-adjusted excess return. It isolates the performance generated by the asset's intrinsic strength rather than broad market momentum:

$$\alpha = \text{Asset Return}_{\text{total}} - (\beta \times \text{Bench Return}_{\text{total}})$$

Where:

* $\text{Asset Return}_{\text{total}} = \frac{P_{A, W-1} - P_{A, 0}}{P_{A, 0}}$
* $\text{Bench Return}_{\text{total}} = \frac{P_{B, W-1} - P_{B, 0}}{P_{B, 0}}$

---

## 3. MQL5 UI & Performance Architecture

* **Single-Point $O(1)$ Optimization:**
  Traditional dashboards loop through 3,000 historical bars for every asset, causing extreme CPU overhead. `AlphaBeta_Dashboard_Pro` optimizes this by copying exactly $W$ bars. It computes only the **current live bar** value for each asset row, reducing the calculations by **99.9%** and ensuring instant, fluid execution for up to 30+ symbols simultaneously.

* **200ms High-Frequency Tick Throttling:**
  Inside `OnCalculate`, a millisecond-level throttle limits updates to 5 times per second (200ms). This prevents terminal freeze during aggressive news events and high tick volume periods while maintaining a fluid real-time feel.

* **Self-Reference Protection:**
  When a symbol is evaluated against itself (e.g. `US500` under the S&P 500 benchmark), the calculator skips statistical equations and immediately returns `Alpha = 0.0000` and `Beta = 1.00`. This provides bulletproof protection against divide-by-zero errors and keeps the layout mathematically clean.

* **Dynamic Asset Benchmark Auto-Routing:**
  The dashboard automatically routes each row to its correct benchmark based on the symbol type:
  * **Forex Currency Pairs:** Evaluated against the Dollar Index proxy (`InpForexBench`).
  * **Indices, Commodities, and Crypto:** Evaluated against the S&P 500 (`InpBenchmark`).

* **Click-to-Switch Interactivity:**
  Each symbol button in the first column is an interactive `OBJ_BUTTON` object. Clicking on the button triggers `OnChartEvent` which instantly switches the main chart's symbol to the selected asset, enabling lightning-fast macro analysis.

---

## 4. Parameters

* **Symbols List (`InpCustomSymbols`):** Comma-separated list of symbols (e.g. "EURUSD,XAUUSD,BTCUSD"). Leave empty to scan active Market Watch symbols.
* **Max Symbols (`InpMaxSymbols`):** Maximum number of symbol rows to display in the table.
* **Timeframe (`InpTimeframe`):** The target timeframe to compute Alpha and Beta on.
* **Lookback (`InpLookback`):** The rolling statistical window ($W$) in bars (Default: `60` bars).
* **Global Benchmark (`InpBenchmark`):** Baseline symbol for non-Forex assets (Default: `"US500"`).
* **Forex Benchmark (`InpForexBench`):** Baseline symbol for Forex assets (Default: `"DX"`).

---

## 5. CAPM Performance Quadrants (Asset Selection Matrix)

The interaction of rolling Alpha and Beta values categorizes assets into **Four Performance Quadrants** represented by the matrix below. This structured approach allows traders to make highly optimized portfolio allocation and risk decisions.

| | Low Beta ($\beta < 1.0$) <br>*(Defensive / Lower Volatility)* | High Beta ($\beta > 1.0$) <br>*(Aggressive / Amplifies Market)* |
| :--- | :--- | :--- |
| **Positive Alpha ($\alpha > 0.0$)** <br>*(Risk-Adjusted Outperformer)* | **QUADRANT II (Defensive Outperformer)**<br>• Strong intrinsic strength.<br>• Highly insulated from broad market selloffs.<br>• *Trade:* **BUY (Long)** as a Safe Haven during corrections. | **QUADRANT I (Aggressive Leader)**<br>• Strong intrinsic strength.<br>• Amplifies broad market gains.<br>• *Trade:* **BUY (Long)** for maximum momentum in bull markets. |
| **Negative Alpha ($\alpha < 0.0$)** <br>*(Risk-Adjusted Underperformer)* | **QUADRANT IV (Lagging / Drifting)**<br>• Poor intrinsic strength.<br>• Low volatility risk but drifts sideways or downwards.<br>• *Trade:* **AVOID**. No active institutional support. | **QUADRANT III (Fragile Underperformer)**<br>• Poor intrinsic strength.<br>• Highly sensitive to broader market drops.<br>• *Trade:* **SELL (Short)** as the prime target when markets turn down. |

### Practical Trading Workflows

1. **The Bull Market Strategy:** Seek assets in **Quadrant I** (Green Alpha cell, OrangeRed Beta cell). These are the market leaders with strong institutional backing that will generate the highest momentum returns.
2. **The Bear Market Hedging:** During corrections, rotate your capital into **Quadrant II** assets (Green Alpha cell, LightSkyBlue Beta cell) to preserve equity while still participating in strong, uncorrelated individual moves.
3. **The Shorting Candidate:** Hunt for **Quadrant III** assets (Crimson Alpha cell, OrangeRed Beta cell) to execute highly profitable short trades, as these weak assets are mathematically guaranteed to fall faster and harder than the rest of the market.
