Logarithmic Fair Value Anchor | PWLogarithmic Fair Value Anchor
This indicator overlays a dynamic "fair value" estimate on the price chart, anchored to the momentum and historical relationship of a user-selected reference asset (e.g., gold, broad liquidity proxies, or major indices). It combines logarithmic deviation analysis with relative valuation to adapt to the anchor's behavior, offering a flexible tool for exploring cross-asset divergences, mean-reversion setups, and contextual extremes.
Core Mechanics and Math Overview
The fair value starts with a baseline: an EMA-smoothed ratio of price to the anchor over the lookback period (default 180 bars). This ratio reflects the historical "normal" relationship between the chart symbol and the anchor.
Anchor momentum is added via the smoothed 1-period ROC of the anchor, scaled by a user-adjustable Momentum Influence Scale (default 5.0 — lower values increase responsiveness). This scaled influence is exponentially applied to adjust the baseline ratio. An optional correlation filter weights the adjustment using absolute log-price correlation (with threshold and manual multiplier). The result is DEMA-smoothed (default length 14) for a responsive yet stable fair value line.
Deviation bands are built multiplicatively around this fair value using exp(deviation * level), preserving log-scale compatibility. Three band types are available:
Log Stdev: Standard deviation of log(price / fair value) — dynamic, volatility-responsive.
Static Sigma: Fixed user-defined deviation (default 0.15) — consistent relative widths.
ATR: Relativized ATR converted to log deviation — range-based smoothing for volatile markets.
Bands use asymmetric multipliers (defaults 1.8 upper / 1.25 lower) with three levels, fills, and markers for visual clarity.
Key Features
Anchor Flexibility: Choose from Gold (XAUUSD), Silver (XAGUSD), S&P 500 (SPX), BTC, or experimental proxies (GLI/M2 aggregates from FRED/ECONOMICS data).
Trend and Visuals: Trend detection (price vs. offset fair value) with optional bar coloring, background highlights for extremes, and diamond markers for overbought/oversold.
Enhanced Info Table (toggleable): Shows current fair value, selected anchor, band type, bias (LONG/SHORT/NEUTRAL), trend duration, trend quality (% clean bars), strength rating (icon-based), z-score deviation (effective band multiple in sigmas + approximate percentile), and valuation (Overvalued/Undervalued/Fair).
Customization: Lookback, offset, smoothing, momentum scale, correlation weighting, band type, multipliers, bar color toggle — adaptable to different assets/timeframes.
What Makes This Approach Distinct
The script uses a smoothed price-to-anchor ratio as its baseline, then applies scaled logarithmic momentum influence to create a fair value that respects both history and external dynamics. This differs from pure moving averages or direct ratio models by incorporating cross-asset momentum in a log framework. Band variety and detailed trend quality/strength metrics provide practical tools for navigating volatility regimes and assessing trend reliability — features not commonly combined in one overlay.
Usage Suggestions
Crypto: Anchor to GLI/M2 for liquidity context; ATR bands help manage volatility. Watch high z-score/percentile or low trend quality for reversals.
Equities/Commodities: Gold for inflation views, S&P for market ties; static sigma for stable benchmarks.
General Tips: Use log scale for visual alignment. Offset (default 90) projects fair value forward. Leverage table metrics — e.g., quality >80% for stronger trends, strength icons for momentum conviction, valuation extremes for mean-reversion ideas. Test anchors and scales to fit your market.
This is an exploratory relative-valuation overlay — results vary by anchor, conditions, and settings. Not financial advice; backtest thoroughly and verify independently.
Notes
Pine Script v6; requires access to external symbols via request.security().
Minor repainting possible on realtime bars due to smoothing and external data.
Community feedback welcome for refinements!
Индикатор Pine Script®






















