# Methods

## Currency Network Strength

For each available broker-resolved pair, closed-bar log returns are calculated over 1, 5, 20, and 60 bars. Each horizon return is divided by `1.4826 × MAD(one-bar log returns, 126) × sqrt(horizon)`, with a `1e-6` floor. A pair is down-weighted from 1.0 to 0.5 only when its current spread is more than three times its 126-bar median spread.

Each observation is written as `return(pair) = strength(base) - strength(quote)`. Weighted normal equations are solved with one temporary anchor, after which all eight scores are centered so their sum is zero. A connected rank of seven is mandatory. Horizon strengths are combined with weights 20/25/30/25 percent, then cross-sectionally winsorized at median ± three robust standard deviations. Residual RMS becomes `confidence = max(0, 1 - residual_RMS/3)`.

## Portfolio Exposure & Stress

Every open FX position is read without mutation. Base and profit-currency legs are derived from broker symbol metadata and translated into the account currency through broker conversion symbols. Stop risk is the absolute adverse result of `OrderCalcProfit` from current price to SL. No SL is labelled `UNBOUNDED`, never zero.

The four static stress scenarios are USD +1%, USD -1%, chart base +1%, and one mean daily true range adverse with all position co-movement treated conservatively. P/L uses broker contract specifications through `OrderCalcProfit`.

## Economic Event Risk Map

The indicator queries `CalendarValueHistory` from trade-server time minus 24 hours to plus seven days. Events are filtered by the chart's base/profit currencies and minimum importance, grouped by currency and minute, then drawn as zones and labels. A timer refreshes no more often than every 60 seconds. The last successful result remains cached with an explicit stale age when refresh fails. Alerts are off by default and de-duplicated by event ID and threshold.

## Regime Persistence Map

Efficiency ratio and normalized three-state sign entropy are calculated over 20, 50, and 100 closed bars; each metric uses the median of the three windows. Realized volatility is the sample standard deviation of 20 log returns and is ranked against 252 strictly older rolling estimates. Range expansion is median true range over the latest five bars divided by the median of the preceding 60 bars.

`SHOCK` activates when volatility percentile is at least 90 or expansion at least 1.8. Otherwise `TREND` requires efficiency at least 0.35 and entropy at most 0.90; `RANGE` requires efficiency at most 0.20 and entropy at least 0.95; remaining cases are `TRANSITION`. Shock is immediate on one closed bar. Other state changes require two consecutive closed-bar raw states. Bar 0 is explicitly preliminary.

## Liquidity Friction Monitor

Historical spread points are converted to cost in basis points as `10,000 × spread_points × point / close` and ranked by midpoint percentile against a 240-bar broker-relative baseline. Activity drought is `100 − percentile(log(1 + tick volume))` over the same baseline. The open/previous-close gap is divided by median true range from 120 strictly older bars and mapped to 0–100 at three median ranges.

The composite score is 50% spread percentile, 35% activity drought and 15% gap pressure. `DISLOCATED` has precedence when spread percentile is at least 97.5 or the gap is at least 3×; otherwise `THIN` begins at 70, `NORMAL` at 40 and `LIQUID` below 40. At least 60 valid spread/volume observations are required; unavailable broker data produces no value.

## Jump & Tail Risk Decomposition

Twenty log returns form realized variation `RV = Σr²`. Bipower variation is `(π/2) × (20/19) × Σ|r[j]||r[j+1]|`, and jump variation is clipped to `max(RV − BV, 0)`. Jump and continuous shares sum to 100 when RV is positive. Downside semivariance share is the fraction of RV contributed by negative returns; a fully flat window is assigned a neutral 50%.

The current return is compared with the median and `1.4826 × MAD` of 252 strictly older returns, with a numerical floor. State precedence is tail surprise at least 6 MAD units, jump share at least 35%, then downside share at least 70% when the current return is negative. The 20-bar volatility output is `100 × sqrt(RV)` and is deliberately not annualized.
