INVITE-ONLY SCRIPT
Updated

Drawdown Defense Engine [AGPro Series]

319
Drawdown Defense Engine [AGPro Series]


🧠 Core Idea

Given current market conditions, should I be sizing up, sizing down, or defending capital?
A risk governor that reads the market's "weather" before you commit size.


📌 Overview / What it does

Drawdown Defense Engine is a market-condition risk governor. It reads four
environmental risk factors - volatility level, volatility trend, trend clarity,
and drawdown from the recent high - and combines them into a single 0-100 Risk
Environment Score.

From that score it produces a four-state regime (Defensive, Cautious, Normal,
Favorable), a recommended relative risk multiplier (0.25x to 1.0x), and an
ATR-based suggested stop distance for the current volatility.

What it does NOT do: it does not predict price direction, it does not tell you
to go long or short, it does not read your account or calculate a dollar
position size, and it does not automate anything. It scores the conditions you
are trading in, so risk decisions stay disciplined.


🎯 Purpose & Design Philosophy

Most risk tools do one of two things: size positions from account equity, or
plot a single volatility metric. The gap is the moment that actually hurts
accounts - taking full-size risk in hostile conditions: high volatility,
choppy structure, or an ongoing drawdown.

Drawdown Defense Engine fills that gap. It is a defensive layer that sits above
any strategy and answers one question: are conditions clean enough to press, or
is it time to protect capital? It is built for discretionary traders who want a
disciplined "risk weather report" rather than another entry signal.


⚡ Why This Script Is Different

Most tools focus on entries, signals, or account-based position sizing.
This script does NOT generate entries, does NOT read your account, and does NOT
point a direction.
Instead, it scores the environment's risk and recommends a relative risk
multiplier - a capital-protection layer that works the same whether you are long,
short, trending, or ranging. Direction-agnostic by design.


⚙️ Methodology

1. Volatility Level
Current ATR is compared to its longer baseline average. Elevated volatility
reads hostile; calm volatility reads favorable.

2. Volatility Trend
ATR now versus ATR a few bars ago. Expanding volatility reads hostile;
contracting volatility reads favorable.

3. Trend Clarity
An efficiency ratio measures how directional recent movement is. A clean,
efficient move reads favorable; choppy back-and-forth reads hostile.

4. Drawdown Stress
The percentage distance below the recent rolling high, used as a market
stress proxy. Near the highs reads favorable; a deep decline reads hostile.

Each factor is scored Favorable / Caution / Hostile, then averaged into the
0-100 Risk Environment Score. The score is discretized into the four-state
regime, which is debounced and confirmed with a hysteresis dead-band so the
state and its markers reflect committed shifts, not noise. The state then maps
to the recommended risk multiplier and the ATR-based suggested stop.


🗺️ How to Read the Chart

• Volatility envelope (EMA +/- ATR): the band width tracks volatility - wide
means turbulent, narrow means calm.
• Background tint = risk regime: green favorable, amber cautious, red defensive
(toggleable).
• Right-edge readout box with a centered label = current State and risk
multiplier.
• "Risk On" / "Risk Off" markers = confirmed regime shifts (resume risk /
reduce risk).
• Panel = the four factors, the Risk Score, the State, the recommended Risk
Size, and the suggested Stop.


🚦 Signals & States

• Favorable -> clean conditions; normal risk (1.0x)
• Normal -> acceptable conditions; slightly reduced (0.75x)
• Cautious -> deteriorating conditions; cut risk (0.5x)
• Defensive -> hostile conditions; minimal risk or stand aside (0.25x)
• Risk On -> environment crossed up into tradeable territory
• Risk Off -> environment crossed down into reduce-risk territory

Interpretations are neutral and describe conditions, not outcomes.


🔔 Alerts Logic

• Risk On -> conditions turned favorable (crossed up)
• Risk Off -> conditions turned defensive (crossed down)
• Defensive (Strong) -> entered the deepest defensive regime

Alerts are attention markers, not trade instructions.


🧩 Confluence Logic

When volatility is low AND contracting AND the trend is efficient AND drawdown
is shallow, the score is high and the regime is favorable - several risk factors
aligning strengthen the read. The reverse is also true: when multiple hostile
factors stack, the defend signal is stronger and more reliable.


📊 When to Use

• As a pre-trade risk filter on any symbol or timeframe
• To scale a strategy's risk up or down with conditions
• To recognize hostile regimes (high volatility, chop, drawdowns) before
committing full size
• In trending or ranging markets alike - it judges conditions, not direction


⚠️ When NOT to Use

• As an entry or exit signal
• As a directional call
• On illiquid symbols with erratic, unreliable ATR
• As a literal dollar position-size calculator tied to your account - it outputs
a relative multiplier, not a position size
• During isolated one-off shocks, which can momentarily skew the score


🎛️ Key Inputs

• ATR / Baseline / Volatility Trend lengths -> volatility sensitivity
• Trend Clarity lookback -> the chop-versus-trend window
• Drawdown lookback -> the stress window
• Thresholds (volatility ratios, efficiency, drawdown %, score bands) -> regime
tuning
• Regime Hysteresis & State Confirm Bars -> how decisive the markers are
• Suggested Stop (ATR) -> the risk geometry
• Visual toggles -> envelope, regime background, readout, markers, theme, font
size, panel location


🖥️ Interface & Visual Design

A single merged blue header panel, a clean volatility envelope, a subtle regime
backdrop, moderate alternating markers, and a centered state readout. The intent
is premium, low-clutter, and readable at a glance.


🧪 Practical Usage Workflow

1. Read the panel State and Risk Size.
2. Check which factors are hostile - those are the drivers.
3. Note the suggested stop distance for the current volatility.
4. Scale your own risk accordingly before acting on your own strategy.


🔍 Interpretation Guidelines

Treat the score as a conditions gauge, not a forecast. "Favorable" means
conditions are clean enough for normal risk - it is NOT a buy signal. In a clean
downtrend the state can read Favorable while the Drawdown factor reads Caution.
Always combine the read with your own method and your own directional bias.


🚫 What This Script Is NOT

• Not a prediction engine
• Not financial advice
• Not auto-trading
• Not guaranteed signals
• Not a directional indicator
• Not an account-based position-size calculator


⚠️ Limitations & Transparency

Factor readings differ across timeframes. Shifts in volatility and liquidity
change how the score behaves. The Drawdown factor uses price drawdown from a
rolling high as a stress proxy, so it carries a longer directional context. The
suggested stop is a distance, not a direction. Regime markers are confirmed
shifts and intentionally lag minor wiggles by design.


🧠 Market Context Notes

Risk clusters. Volatility, choppy structure, and drawdowns tend to arrive
together. The engine leans defensive precisely when these stack - which is when
capital is most at risk.


🧾 Use Case Examples

• Volatility expanding + chop + drawdown -> Defensive 0.25x -> hold off or trade
small.
• Volatility contracting + efficient trend + near highs -> Favorable 1.0x ->
trade your setup at normal size.


🧱 System Philosophy

Protect capital first. Edge only compounds if you survive the hostile regimes.
Drawdown Defense Engine is a discipline layer, not a signal source.


🔐 Non-Promise Statement

No guarantees and no certainty. Conditions can change without warning, and past
behavior does not assure future behavior.


📉 Risk Disclosure

Trading involves substantial risk. You are solely responsible for your own
decisions. This script is for educational and analytical purposes only and does
not provide financial advice.


📚 Educational Note

Use Drawdown Defense Engine to build the habit of reading conditions before
sizing. Over time, risk management is the most durable edge a trader has.
Release Notes
UPDATE NOTES - 2.0

This update focuses on depth and proof: grading each risk factor on a continuous
0-100 scale, and adding a forward-risk layer that shows what historically followed
each regime.

The core purpose of the script remains unchanged. It still reads volatility level,
volatility trend, trend clarity and drawdown into one risk-environment score and
suggests sizing risk down in hostile conditions and up in clean ones. This release
deepens HOW each factor is graded and presented, and adds historical context the
previous version did not surface.

This script continues to function as an analytical and visualization tool. It does
not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

- Continuous factor grading
Volatility, Volatility Trend, Trend Clarity and Drawdown are now each graded on a
smooth 0-100 scale instead of three fixed states. The panel shows the number for
each factor, so the composite score is fully auditable.

- Forward-risk proof layer
A new block reports the average drawdown that historically followed each regime over
a configurable horizon: Forward Risk when Defensive versus when Favorable, with the
sample size (n). When the dial is meaningful, defensive regimes precede deeper
drawdowns than favorable ones.

- Action line
The panel now states the suggested next step directly: scale up, normal sizing,
reduce size, or stand aside and defend.

- Cleaner composite
Because the factors are now continuous, the risk score moves smoothly with
conditions rather than in coarse steps.


------------------------
Visual Improvements
------------------------

- Improved chart readability by showing graded factor values in the panel rather
than single-word states.

- Reduced visual clutter by greying the forward-risk rows until enough samples have
accumulated to read them.

- Refined visual hierarchy so the verdict, output and proof blocks are clearly
separated.

- Kept the regime background tint, volatility envelope and Risk On / Risk Off
markers for continuous at-a-glance context.


------------------------
Interface & Usability
------------------------

- Restructured the panel into four blocks: Factor Breakdown, Verdict, Output and
Forward-Risk Proof, separated by divider rows.

- Added a Forward Risk Horizon control so the proof window can be tuned to the
timeframe.

- Adjusted threshold tooltips to reflect the new continuous grading.

- Enhanced overall user experience while keeping panel theme, location and font size
fully adjustable, with the panel shown by default.


------------------------
Behavior Notes
------------------------

This update changes how each factor is graded, expanding it from three states to a
continuous scale, and adds forward-risk statistics. The regime state machine,
hysteresis and markers are unchanged.

The goal is to improve clarity, depth and usability, not to introduce predictive
behavior. The forward-risk numbers describe what followed past regimes within the
visible history and are not forecasts. Small samples should be read with care.

Users should continue to interpret outputs as context, now with a more detailed and
auditable readout.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity and timeframe differences may affect
how the score, regime and forward-risk statistics appear.

Outputs should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
Release Notes
🔧 UPDATE NOTES - 2.0.1

This update focuses on drawdown transparency, confirmed-state stability, threshold safety, interface clarity, and chart readability.

The core purpose of the script remains unchanged. Drawdown Defense Engine still grades volatility level, volatility trend, trend clarity, and rolling-peak drawdown; combines them into one defense-environment score; maps the result into four regimes; and provides a direction-agnostic risk-context overlay.

This release corrects how existing information is displayed and when persistent states are committed. It does not add prediction, automated execution, account-specific sizing, or guaranteed outcomes.


------------------------
What Changed
------------------------

• Actual drawdown display
The panel's Drawdown row now reports the real percentage distance below the rolling high. V2.0 displayed the inverse 0-100 drawdown favorability grade under the Drawdown label, which could make a material decline appear as “0” instead of showing its actual percentage.

• Confirmed-bar regime lifecycle
Candidate-state confirmation, hysteresis transitions, regime markers, and alerts are now committed only after the chart bar closes. Temporary intrabar score movement can no longer create a persistent Risk On, Risk Off, or Defensive event.

• Warm-up integrity
The engine remains in its neutral initialization state until ATR baseline, volatility trend, efficiency-ratio, and rolling-high history are all available. Incomplete early history can no longer be classified as an artificial defensive regime.

• Safe threshold ordering
Internal effective thresholds now preserve valid ordering when users enter overlapping volatility, efficiency, drawdown, or regime-score values. This prevents zero-width or inverted grading ranges without removing any existing input.

• Clearer score terminology
The composite row is now labeled Defense Score, making it clear that a higher number represents a cleaner, more favorable environment rather than greater risk.

• Analytical output wording
Action has been renamed Posture, Risk Size has been renamed Risk Dial, and Suggested Stop has been renamed ATR Reference. The underlying regime mapping and ATR-distance calculation are unchanged; the wording now presents analytical context rather than a direct trading instruction.


------------------------
Visual Improvements
------------------------

• RISK ON and RISK OFF markers now use consistent uppercase wording.

• Teal state and marker labels use dark text for stronger contrast.

• The projected state zone retains a horizontally and vertically centered badge, now formatted as “STATE | DIAL 0.00x”.

• The premium blue merged panel header and established AGPro palette remain unchanged.


------------------------
Interface & Usability
------------------------

• Show Panel remains enabled by default.

• Disabling Show Panel now clears the complete table immediately, preventing stale panel content from remaining on the chart.

• Panel theme, panel location, panel font size, label font size, volatility envelope, regime background, projected state readout, and marker controls remain available.

• The first panel row remains one merged blue row containing only “AG Pro Drawdown Defense Engine.”


------------------------
Behavior Notes
------------------------

This update preserves the four factor definitions, 25% / 20% / 20% / 35% composite weights, four-state regime architecture, confirmation-bar count, hysteresis buffer, regime-to-dial mapping, ATR reference calculation, volatility envelope, background regime map, projected state zone, forward-drawdown methodology, and alert set.

Historical forward-drawdown sample counts may change slightly because incomplete warm-up history is no longer allowed to create synthetic regime observations.

The Drawdown row is intentionally no longer comparable numerically with V2.0: it now shows actual drawdown percentage, while the composite calculation continues to use the same internal 0-100 favorability grade.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical and visualization tool.

Rolling-high drawdown depends on the selected lookback. ATR, efficiency ratio, volatility baseline, timeframe, symbol liquidity, and current market regime can materially affect the displayed context.

Forward-drawdown rows summarize historical observations visible on the loaded chart. They are descriptive samples, not forecasts.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice, automated execution, account-specific position sizing, or guaranteed trading outcomes.

Users remain responsible for their own decisions and risk management.
Release Notes
🔧 UPDATE NOTES - V2.0.2

• Refreshed the publication and access routing information.
• Core drawdown-defense logic, panel behavior, inputs, alerts, visuals, and outputs remain unchanged.
Release Notes
🔧 UPDATE NOTES - V2.1.0

This update focuses on decision hierarchy, forward-risk evidence, chart restraint, and label separation.

The core purpose of the script remains unchanged.
This release improves how the existing drawdown-defense model is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

• Added a decision-defining panel question
“HOW DEFENSIVE IS THIS MARKET?” now frames the panel around the script’s central analytical purpose.

• Added sample-qualified forward-risk evidence
Defensive and favorable forward-drawdown observations now require at least 30 samples on both sides before the panel labels their separation as established.

• Added a direct drawdown-separation measure
The panel now reports the percentage-point difference between average forward drawdown after defensive and favorable regimes.

• Reorganized the panel
Current state, defense score, risk dial, posture, drawdown, factor mix, ATR reference, and evidence now follow one compact hierarchy.

• Preserved the analytical model
Volatility, volatility trend, trend clarity, drawdown grading, regime confirmation, hysteresis, and alert conditions remain unchanged.


------------------------
Visual Improvements
------------------------

• Reduced the opacity of regime backgrounds so candles remain dominant

• Reduced volatility-envelope fill density for a cleaner chart

• Removed empty panel separator rows

• Added opaque alternating rows for stronger Dark and Light theme readability

• Moved the projected state card farther into future chart space

• Reduced collision risk between the state card and current regime markers


------------------------
Interface & Usability
------------------------

• Panel visibility, location, theme, and font size remain configurable

• Label font size, offset, projection distance, and marker density remain configurable

• Factor scores are condensed into one readable row

• Evidence maturity and sample counts are now explicit


------------------------
Behavior Notes
------------------------

This update does not change the core risk-state logic of the script.

The goal is to improve clarity, evidence interpretation, and usability, not to introduce predictive behavior.

The Risk Dial remains a context output derived from the current regime. It is not account-specific position-sizing advice.


------------------------
Limitations Reminder
------------------------

Forward-drawdown statistics depend on the available chart history, symbol, timeframe, selected horizon, and model settings.

A historical separation between regimes does not guarantee the same relationship in future market conditions.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
Release Notes
Version 2.2.0 – Defense Regime Visual Clarity

This update strengthens the direction-agnostic defense workflow while preserving the four-factor environment model, regime lifecycle, risk dial, forward-drawdown evidence, and alerts.

• Disabled the full-chart regime tint by default, removing persistent vertical color bands while keeping the background map available as an optional setting.

• Preserved the volatility envelope as the primary continuous chart structure so changing market stress remains visible without obscuring candles.

• Rebuilt the projected state readout as a centered two-line defense card showing regime, Defense Score, Risk Dial, and current drawdown.

• Moved the live defense card farther into future space and extended its envelope-owned band, preventing the current verdict from competing with the latest candles.

• Converted the panel State value into a contrast-safe filled decision cell, strengthening the hierarchy between regime verdict and supporting evidence.

• Reduced historical regime-marker density with a 52-bar cooldown, a six-marker cap, and a larger default ATR offset.

• Preserved the panel's merged blue title row, analytical question row, theme and location controls, and shared font-size settings.

• Preserved the volatility, volatility-trend, trend-clarity, and rolling-drawdown factors; weighted Defense Score; confirmed regime state machine; forward-risk proof layer; and all three alert conditions.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.