OPEN-SOURCE SCRIPT
Zaktualizowano

AG Pro Correlation Stress Meter [AGPro Series]

619
AG Pro Correlation Stress Meter [AGPro Series]

Overview / What it does

AG Pro Correlation Stress Meter is an overlay indicator designed to estimate when an instrument is becoming increasingly synchronized with a selected benchmark and whether that relationship is developing into a higher-stress market condition.

Instead of treating correlation as a standalone number, this script converts multiple correlation-related components into a structured stress framework. The goal is not to predict direction. The goal is to help the user judge whether market behavior is becoming more tightly linked, more fragile, and potentially less independent than usual.

The script combines smoothed rolling correlation, short-term correlation acceleration, persistence of elevated correlation, and a simple fragility layer based on price behavior versus an internal backbone EMA. The result is a normalized stress score and a state model that classifies conditions as Stable, Building, Pressured, Stressed, or Critical.

Because the script is plotted directly on price, it is intended to function as a context layer. It can be used to evaluate whether a chart is trading in a relatively independent manner or whether it is increasingly behaving like a benchmark-driven instrument.

Unique Edge

The main difference in this script is that it does not treat correlation as a single readout. It treats correlation as a pressure structure.

Many correlation tools stop at the raw coefficient. This script goes further by asking four separate questions:
1. How strong is the current relationship?
2. Is that relationship tightening or loosening?
3. Has elevated correlation persisted for long enough to matter?
4. Is price behavior becoming fragile at the same time?

That combination is what makes this script different from many standard overlays, matrix-style correlation displays, or simple coefficient dashboards.

It is also different from several other AG Pro scripts in the catalog. Some AG Pro tools focus on trend quality, pullback quality, squeeze behavior, reclaim structure, momentum pressure, or reaction mapping around known reference levels. This script does not focus on any of those themes. Its job is narrower and more diagnostic: it measures how much benchmark-linked stress is building inside the chart. In other words, it is less about trend or structure classification, and more about whether the instrument is becoming increasingly dependent on external benchmark behavior.

Methodology

The script starts with log returns for both the chart symbol and the selected benchmark symbol. A rolling correlation is then calculated over the chosen correlation window and smoothed to reduce noise.

From there, the model evaluates four components:

1. Correlation strength
This is the normalized level of the smoothed rolling correlation. Higher positive correlation generally contributes more to the final stress score.

2. Correlation velocity
This measures how much the smoothed correlation has changed over a short lookback. A rising relationship can matter even when the absolute coefficient is not yet extreme.

3. Correlation persistence
This evaluates how consistently correlation has remained above a user-defined threshold over a recent window. Short spikes and sustained linkage should not be treated as the same condition, so persistence is included as a separate layer.

4. Fragility layer
This component looks at whether price is trading below the internal backbone EMA, whether short-term rate of change is weak, how stretched price is relative to the EMA, and whether ATR percentage is elevated. The purpose of this layer is not to predict reversals. Its purpose is to distinguish a calm, orderly correlation regime from a more fragile one.

These components are weighted into a composite stress score, then mapped into five states:
- Stable
- Building
- Pressured
- Stressed
- Critical

The script also provides a backdrop layer, optional event labels, a backbone EMA for context, and a compact information panel.

Signals & Alerts

This script is primarily a state-classification and context tool. It is not a direct entry system and should not be interpreted as a standalone buy or sell engine.

Available alert logic includes:
- Stress Building
- Stress Pressured
- Stress Stressed
- Stress Critical
- Stress Cooling

These alerts are designed to notify the user when the internal state model changes. They can be used to monitor regime transitions, benchmark sensitivity changes, or shifts in how tightly a symbol is tracking the selected benchmark.

Practical interpretation examples:
- Building may suggest that correlation-linked influence is starting to develop.
- Pressured may suggest that the relationship is no longer background noise and is becoming relevant to decision-making.
- Stressed may suggest that the symbol is trading with notable benchmark dependency.
- Critical may suggest that benchmark-linked pressure is unusually elevated relative to the script’s internal framework.
- Cooling may suggest that the prior stress state is easing.

These are contextual interpretations, not trade instructions.

Key Inputs

Benchmark Symbol
Selects the reference instrument used for the correlation calculation.

Benchmark Timeframe
Allows the benchmark series to follow the chart timeframe or use a different one.

Correlation Length
Defines the rolling window used for correlation.

Correlation Smoothing
Smooths the raw correlation series.

Velocity Lookback
Controls how quickly changes in correlation are measured.

Persistence Window
Defines how far back the script checks for sustained elevated correlation.

Persistence Threshold
Defines what the script considers “elevated” for persistence purposes.

Fragility EMA Length
Controls the internal backbone EMA used in the fragility layer and optional overlay line.

Fragility ROC Length
Defines the short-term price change measurement inside the fragility model.

ATR Length
Controls the volatility input used in the fragility model.

Label Trigger State
Sets the minimum state required before labels can appear.

Minimum Bars Between Labels
Reduces label clustering.

Background From State
Sets the minimum state required before the stress backdrop is shown.

Label ATR Offset
Controls how far event labels are plotted from price.

Panel / Visual Inputs
Allow control over panel visibility, panel position, panel theme, panel font size, label size, backdrop visibility, backbone visibility, and backbone label visibility.

Limitations & Transparency

This script is a contextual model, not a statement of causality. A high reading does not prove that the benchmark is causing the move. It only indicates that the symbol is trading in a way that is more tightly aligned with the selected benchmark according to the model inputs.

Correlation is also regime-dependent. A symbol may appear highly linked during one period and much less linked during another. Different benchmarks, timeframes, and windows can produce different readings.

The fragility layer is intentionally simple. It is included to refine the stress framework, not to replace full market structure analysis. Users who rely on this script should still examine trend structure, volatility context, liquidity conditions, and the behavior of the benchmark itself.

This script also does not claim to identify tops, bottoms, crashes, breakouts, or future returns. It measures an internal definition of correlation-linked stress and presents that information visually.

Risk Disclosure

This indicator is for analytical and educational use. It does not provide financial advice, investment advice, or guaranteed outcomes.

No indicator can remove market risk. Correlation regimes can change quickly, benchmark relationships can decouple without warning, and any model based on historical data can fail in live conditions.

This tool should be used as one part of a broader chart review process, not as a substitute for independent judgment, risk management, or position sizing discipline.
Informacje o Wersji
UPDATE NOTES - V1.1

This update is focused on visual presentation and chart readability.

The core purpose of the script remains the same: it maps periods where benchmark correlation pressure is building, stressed, or critical, while keeping that pressure context readable directly on the price chart. This release does not reframe the tool as a prediction engine and does not introduce any performance claims.

What changed in V1.1

1) Backbone EMA presentation was refined
The backbone EMA now has a more polished visual footprint on the chart, making the reference line easier to follow during stressed phases and transition phases without overwhelming price.

2) A soft EMA support zone was added
A light visual zone was added around the backbone structure to improve context visibility. The intent is to make the script feel more anchored and visually complete while still preserving candle readability.

3) Stress labels were cleaned up
Stress event labels were tightened into a more compact visual style so they remain noticeable without taking too much chart space. This helps the chart stay organized during repeated stress transitions.

4) Panel presentation was improved
The dashboard styling was refined so state, score, and benchmark context are easier to read at a glance. The stressed-state presentation now has stronger visual emphasis without changing the underlying scoring logic.

5) Overall chart cohesion was improved
This version aims to make the script look more intentional and easier to interpret during live chart use. The update is primarily about visual hierarchy, consistency, and presentation quality.

What did not change

- The underlying stress framework remains the same.
- The score still reflects the script’s existing correlation, velocity, persistence, and fragility structure.
- State thresholds were not redesigned.
- The script is still intended as a contextual decision-support tool, not a standalone trading system.
- Existing alert semantics remain aligned with the documented state transitions.

Notes

This is a presentation-focused update intended to improve usability and first-look clarity. It should be easier for users to identify the backbone structure, read the current stress state, and visually track stress episodes on the chart without materially changing how the script behaves.

Risk Disclosure

This script is provided for informational and educational use only. It does not guarantee outcomes and should not be used as a substitute for independent analysis, risk management, or a broader trading process.
Informacje o Wersji
Update Notes - V1.3

This update focuses on cleaner chart presentation, more structured stress evaluation, and better signal selectivity. The goal was to make the script easier to read in live use while keeping the methodology transparent and behavior more controlled.

What changed in this update:

- Refined the stress model with a broader dependency framework.
The script now supports an Absolute dependency basis in addition to positive-only dependency logic, which helps evaluate stronger benchmark linkage in a more flexible way.

- Added a Benchmark Shock component.
Stress scoring now includes benchmark ATR-based shock pressure, so the model can better reflect periods where benchmark volatility may increase cross-asset stress conditions.

- Added Link Mode to the panel.
The panel now shows whether the current benchmark relationship is Positive or Inverse, which gives additional context without adding extra chart clutter.

- Rebuilt the panel layout.
The first row now uses the standardized AG Pro blue merged header format with the script name only, and the default panel font is now Small for a cleaner visual footprint.

- Improved chart readability.
The backbone EMA, glow, and backbone zone were rebalanced to reduce visual weight so price candles remain easier to follow.

- Reduced label repetition.
Stress labels are now more selective through a longer cooldown and a minimum score-change filter, which helps avoid unnecessary repetition during similar stress phases.

- Improved label placement behavior.
Labels now adapt more cleanly to chart position, which helps preserve readability during rising and falling stretches.

- Smoothed the background transition effect.
Stress backdrop behavior was refined to keep state transitions visible without making the chart feel overcrowded.

How to read this version:

- Stress Score summarizes the current benchmark-linked pressure environment.
- State classifies that environment into Stable, Building, Pressured, Stressed, or Critical.
- Link Mode shows whether the current dependency is moving in a positive or inverse relationship to the selected benchmark.
- Backbone EMA is a visual reference layer and should be treated as context, not as a standalone trade signal.

Notes:

This script is a contextual market-relationship tool. It is designed to help evaluate benchmark dependency and stress conditions, not to forecast price direction on its own. Best use comes from combining it with structure, liquidity, trend, and risk management frameworks.

Risk Disclosure:

This indicator is for analysis and educational use only. It does not provide financial advice, does not guarantee outcomes, and should not be treated as an automated decision system.
Informacje o Wersji
Update Notes - V1.4

This update focuses on sharper chart presentation, stronger identity, and better live-read usability while keeping the script centered on benchmark-linked stress rather than relationship breakdown.

What changed

- Removed the `AG Pro` prefix from the published script title while keeping the AG Pro identity inside the panel header.
- Rebuilt the top panel row into the standardized single merged blue header format.
- Refreshed the full panel theme with the current AGPro color palette and cleaner dark/light behavior.
- Added a `Primary Driver` readout so users can immediately see whether current stress is led by raw correlation, persistence, fragility, velocity, or benchmark shock transfer.
- Upgraded the benchmark shock model by combining benchmark ATR pressure with benchmark EMA displacement, making stress escalation feel more event-aware.
- Added optional long rectangular `Stress Zones` that print only when the model escalates into higher-risk states, improving chart memory without overloading the view.
- Reworked the backbone band so the overlay feels more alive and state-aware while remaining restrained enough for live chart work.
- Improved live label spacing so event tags stay visible and do not get buried inside candle structure.
- Kept label density intentionally controlled for a more premium published appearance.

What did not change

- The script is still a benchmark-dependency stress tool, not a decoupling or relationship-failure map.
- The update does not reposition the indicator as a direct buy/sell engine.
- Alerts remain state-based and should still be treated as contextual workflow triggers.

Practical effect

In live use, the script should now feel more intentional, easier to read, and more distinctive on chart. The update is built to make the indicator more visually memorable while preserving its original analytical purpose.
Informacje o Wersji
🔧 UPDATE NOTES - V1.5

This update focuses on readability, structure, visual clarity, and publication-grade usability.

The core purpose of the script remains unchanged.
This release improves how benchmark dependency, correlation persistence, shock transfer, and internal fragility are presented 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
------------------------

• Rebuilt the visual structure around an active correlation stress corridor.
Elevated stress states now create a cleaner projected corridor with centered text and a midpoint guide.

• Added a clearer decision-style panel.
The panel now emphasizes Stress Score, State, Benchmark Link, Primary Driver, and Action instead of a long diagnostic stack.

• Added right-side context tags.
The chart now displays compact tags for stress score, benchmark link, shock transfer, and current action context.

• Improved stress memory zones.
Completed stress corridors can now remain on the chart as faded memory zones for better structural context.

• Refined event labeling.
State labels are more selective and controlled by density settings to reduce clutter while preserving a premium chart layout.


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

• Improved chart readability by adjusting the stress backbone, active corridor, right-side tags, and event label spacing.

• Reduced visual clutter by using selective stress labels and limited memory zones.

• Refined visual hierarchy so benchmark dependency, shock transfer, stress state, and action context stand out more clearly.

• Adjusted positioning of elements to avoid overlap with candles and improve first-glance interpretation.


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

• Optimized panel layout for clearer information flow.

• Added configurable panel visibility, panel location, panel theme, panel font size, and label font size.

• Kept label text size default at Normal for better chart readability.

• Enhanced overall user experience without changing the script into an automated signal system.


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

This update does not change the core analytical purpose of the script.

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

Users should interpret outputs as benchmark-relative stress context:
correlation pressure, persistence, shock transfer, internal fragility, and stress cooling.


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

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, timeframe differences, benchmark selection, and sudden news-driven moves may affect how stress states 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.
Informacje o Wersji
UPDATE NOTES - V1.6

This update focuses on visual clarity, panel structure, label readability, and public-chart usability.

The core purpose of the script remains unchanged.
This release improves how the existing correlation-stress logic 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
------------------------

* Standardized panel controls for the current AGPro visual baseline.
Panel Location, Panel Theme, Panel Font Size, and Show Panel controls are now aligned with the newer public refresh standard.

* Preserved the single merged blue AG Pro panel header.
The panel header remains a clean one-row title area while the script title itself stays free of the AG Pro prefix.

* Improved chart-facing label language.
Event labels, corridor labels, memory-zone text, and right-side tags now use compact uppercase formatting for a stronger publication look.

* Refined right-side tags for score, benchmark link, shock transfer, and action context.
The tags are more compact and easier to read at the active edge of the chart.

* Focused the active stress corridor on the current stress window.
The corridor now uses a rolling active lookback so it does not expand across the full historical chart when stress remains elevated for a long period.

* Added a thin connector line from the active stress backbone to the right-side action context.
This makes the tag cluster feel connected to the current chart structure rather than floating without context.


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

* Improved chart readability by keeping the stress backbone and corridor as the primary visual story.

* Reduced event-label crowding by increasing default spacing and keeping fewer labels in memory.

* Replaced multi-line event labels with compact single-line uppercase badges.

* Refined active corridor and memory-zone text so the zone story remains readable in screenshots.

* Improved right-edge tag stacking to reduce collision risk around the latest candle.

* Softened corridor and background opacity so price action remains the visual priority.


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

* Kept Show Panel enabled by default.

* Renamed Panel Position to Panel Location.

* Renamed Panel Text Size to Panel Font Size.

* Renamed Label Text Size to Label Font Size.

* Expanded the panel flow with Stress Score, State, Benchmark, Driver, Shock, and Action.

* Preserved the merged blue panel header with only the AG Pro panel title.


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

This update does not change the core analytical logic of the script.

The rolling correlation, persistence, dependency velocity, benchmark shock transfer, internal fragility, and final stress score model remain aligned with the previous version.

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

Users should interpret outputs the same way as before, but with improved visual structure and faster context recognition.


------------------------
Alerts Logic
------------------------

Alerts remain attention markers.

They trigger when the model enters Pressured, Stressed, or Critical states, or when stress cools from a higher state.

Alerts are designed to highlight changes in correlation-stress context.
They are not trade entries, exits, buy/sell commands, or guaranteed outcome signals.


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

The script remains a rule-based analytical tool.

Benchmark selection, timeframe differences, volatility, liquidity, and symbol behavior may affect how correlation-stress states 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.
Informacje o Wersji
UPDATE NOTES - V1.9

This update focuses on right-side context badge readability.

The core purpose and analytical model remain unchanged.

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

* Converted right-side context tags into no-arrow badges.
The score, benchmark sync, benchmark volatility shock, and action tags no longer use pointer-style label arrows.

* Reduced visual ambiguity.
The benchmark sync and shock badges are context information, not stress-zone labels. Removing the arrow prevents them from appearing as if they point to an empty zone or price level.

* Renamed the visual setting to Right-Side Context Badges.
This better describes what these objects do on the chart.

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

This update does not change scoring, thresholds, alerts, zones, panel rows, or the correlation model.

It only improves the visual meaning of the right-side context labels.

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

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.
Informacje o Wersji
🔧 UPDATE NOTES - v2.0

This update adds a risk-off follow-through proof and streamlines the layout.

The core purpose of the script remains unchanged.
It continues to measure benchmark-relative correlation stress, persistence, dependency
velocity, shock transfer and internal fragility with the same engine.

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
------------------------

- Risk-Off Rate proof layer
The panel now reports how often Stressed or Critical escalations were historically followed
by a downside move before an equal upside move, shown with the sample count for transparency.

- Risk-Off Proof Window input
A new setting controls the window used to measure post-escalation follow-through.

- Cleaner panel-first layout
The right-side context tags duplicated the panel and crowded the latest candles, so they
were removed. The panel remains the single, uncluttered source for score, state and action.

- Honest, conservative counting
Each escalation is counted once, and an upside-first move or window expiry is treated as a
non-confirmation, so the rate stays realistic on the selected market and timeframe.

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

- Removed the crowded right-edge tag stack near the latest bar

- Preserved the stress backbone, corridor, memory zones and centered badges

- Maintained contrast-safe corridor and memory labels

- Reduced clutter for a cleaner first-glance read

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

- Added a Risk-Off Rate row for an at-a-glance follow-through track record

- Added a window setting so the proof measures prompt follow-through

- Kept the score, state, benchmark, driver, shock and action hierarchy

- Enhanced overall user experience without changing the core stress logic

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

This update does not change the core analytical logic of the script.

The stress score, states, corridor and drivers are unchanged. The Risk-Off Rate is a separate
historical track-record layer and does not alter how stress is computed.

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

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, and timeframe differences may affect how
stress states and the rate 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.
Informacje o Wersji
Version 2.1 – Proof Integrity and Compact Stress Memory

This update strengthens the historical proof layer and gives the stress-corridor story a clearer visual hierarchy while preserving the benchmark-correlation, dependency velocity, persistence, shock-transfer, fragility, composite-score, and state-threshold engine.

• Rebuilt the historical proof as independent overlapping samples so every confirmed Stressed or Critical escalation can resolve without a newer event being silently skipped.

• Froze each proof sample’s ATR distance at escalation and measured only confirmed-close follow-through, then renamed the panel metric to Downside Follow for more precise interpretation.

• Corrected escalation and cooling transitions so a downgrade from Critical to Stressed or Stressed to Pressured can no longer be mislabeled or alerted as fresh stress escalation.

• Let Stressed and Critical transition labels bypass the low-priority cooldown, added the event score to every badge, and increased candle clearance without exceeding the selected label-memory limit.

• Capped completed memory-zone history to the active corridor lookback, reduced the default memory count and projection, and stored peak state, peak score, and episode duration in each centered badge.

• Upgraded the active corridor badge with current state, score, and primary driver, and added a price-bearing Stress Mid tag to identify the visible midpoint guide.

• Replaced the misleading letter grade with stress-intensity bands, added the selected benchmark symbol to the panel, highlighted the primary driver, and replaced the duplicated Action row with a state-aware Workflow row.

• Reduced label, line, and box budgets to match actual bounded object usage while preserving panel, theme, position, font-size, corridor, memory, backdrop, and alert controls.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.