OPEN-SOURCE SCRIPT
US Leverage Overlay — Margin Debt & Total Credit (YoY / Z-score)

What this does
An overlay indicator that brings U.S. leverage proxies from FRED onto your main price chart (left axis). Choose between a proxy for investor margin debt or total credit market debt and view them as YoY %, Z-score of YoY, or an Indexed Level so they’re comparable with price without wrecking the scale.
Data sources (FRED symbols)
--- Margin (investor leverage proxy): FRED:BOGZ1FL663067003Q
Brokers & Dealers; Receivables Due from Customers ≈ margin loans (quarterly).
--- TotalCredit (economy-wide leverage): FRED:TCMDO
All sectors; Debt Securities & Loans; Liability (quarterly).
Note: These are quarterly series. The indicator samples monthly and holds values between official prints, so you’ll see step-like updates when new data drops.
Views (pick one in settings)
--- YoY % — 12-month rate of change. Above 0% = leverage expanding; below 0% = contracting.
--- Z-score (YoY) — Standardizes YoY vs. its recent history to flag unusual moves (regime shifts).
--- Indexed Level — 100 × (level / moving average), a compact “above/below trend” view.
How to read quickly
--- Rising YoY % > 0 → leverage expansion (often supportive for risk).
--- Falling YoY % < 0 → deleveraging headwind.
--- Z-score spikes (±2) → unusually fast changes; watch for volatility or policy inflections.
--- Indexed Level crossing down through 100 → slipping below trend.
Inputs
--- Data source: Margin or TotalCredit
--- YoY/Z-score lookbacks and Index baseline length
--- Overlay: overlay=true, scale=scale.left (uses its own left axis by default)
Tips
--- If it spawns in a sub-pane, right-click the label → Move to → Main chart.
--- For context, consider adding related series on separate panes:
FRED:TOTALSL (Consumer Credit), FRED:REVOLSL (Credit Cards),
FRED:BUSLOANS (C&I Loans), FRED:TDSP (Debt Service Ratio).
--- Occasionally FRED returns “Failed to fetch”; re-add or reload fixes it.
Why it’s useful
Equity drawdowns often line up with turns in leverage (households, corporates, or brokers). This overlay gives you a clean, normalized read so you can spot expansion vs. contraction alongside price action.
Compatibility
--- Pine Script® v6
--- Works on any chart timeframe (data internally sampled monthly)
Educational use only — not financial advice.
An overlay indicator that brings U.S. leverage proxies from FRED onto your main price chart (left axis). Choose between a proxy for investor margin debt or total credit market debt and view them as YoY %, Z-score of YoY, or an Indexed Level so they’re comparable with price without wrecking the scale.
Data sources (FRED symbols)
--- Margin (investor leverage proxy): FRED:BOGZ1FL663067003Q
Brokers & Dealers; Receivables Due from Customers ≈ margin loans (quarterly).
--- TotalCredit (economy-wide leverage): FRED:TCMDO
All sectors; Debt Securities & Loans; Liability (quarterly).
Note: These are quarterly series. The indicator samples monthly and holds values between official prints, so you’ll see step-like updates when new data drops.
Views (pick one in settings)
--- YoY % — 12-month rate of change. Above 0% = leverage expanding; below 0% = contracting.
--- Z-score (YoY) — Standardizes YoY vs. its recent history to flag unusual moves (regime shifts).
--- Indexed Level — 100 × (level / moving average), a compact “above/below trend” view.
How to read quickly
--- Rising YoY % > 0 → leverage expansion (often supportive for risk).
--- Falling YoY % < 0 → deleveraging headwind.
--- Z-score spikes (±2) → unusually fast changes; watch for volatility or policy inflections.
--- Indexed Level crossing down through 100 → slipping below trend.
Inputs
--- Data source: Margin or TotalCredit
--- YoY/Z-score lookbacks and Index baseline length
--- Overlay: overlay=true, scale=scale.left (uses its own left axis by default)
Tips
--- If it spawns in a sub-pane, right-click the label → Move to → Main chart.
--- For context, consider adding related series on separate panes:
FRED:TOTALSL (Consumer Credit), FRED:REVOLSL (Credit Cards),
FRED:BUSLOANS (C&I Loans), FRED:TDSP (Debt Service Ratio).
--- Occasionally FRED returns “Failed to fetch”; re-add or reload fixes it.
Why it’s useful
Equity drawdowns often line up with turns in leverage (households, corporates, or brokers). This overlay gives you a clean, normalized read so you can spot expansion vs. contraction alongside price action.
Compatibility
--- Pine Script® v6
--- Works on any chart timeframe (data internally sampled monthly)
Educational use only — not financial advice.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.