OPEN-SOURCE SCRIPT
Actualizado

Dynamic Support and Resistance with Trend Lines

44 645
Dynamic Support and Resistance with Trend Lines (DSRTL)

1. Introduction & Methodology
The DSRTL indicator is designed to provide a multidimensional analysis of market structure. Unlike traditional tools that rely solely on price pivots, this script combines Static Volume-based Zones with Dynamic Trend Lines to evaluate the price's position relative to critical market components.

The S/R Identification Technique
Instead of standard pivot points, DSRTL utilizes Volume Analysis to highlight areas of significant trader participation:
- Strategy A:
Matrix Climax: Identifies candles within the lookback period that are near price extremes (Highs/Lows) and coincide with significant buying or selling volume.
- Strategy B:
Volume Extremes: Detects candles with the absolute highest buy/sell volumes within the selected lookback window, creating extreme volume-based S/R zones.
- Result:
This creates Support/Resistance (S/R) zones that are validated by actual market activity, not just price geometry.

Dynamic Trend Lines
To complement the static zones, the indicator employs two adaptive channel methods:
- Pivot Span: Connects recent significant pivots for a fast, reactive trend corridor.
- 5-Point Channel: Segments the lookback period into 5 parts to perform a linear regression analysis, creating a stable and statistically significant channel.

2. Volume Calculation Methodology
Accurate S/R detection requires distinguishing Buy Volume from Sell Volume. DSRTL offers two calculation modes:

- Geometry (Source File): Estimates buy/sell volume based on the Close price's position relative to the High/Low of the candle.
Note: This is an approximation that works on all plan types as it does not require intrabar data.

- Intrabar (Precise): Analyzes historical lower-timeframe data (e.g., 15S) to calculate intrabar-based volume deltas with higher precision compared to the geometric method.

Note: This offers superior accuracy. It requires access to historical intrabar data (depending on your plan limits). For the best analytical results, use this mode if available.

3. The Smart Matrix Engine (3D Analysis)
The core of DSRTL is its dashboard, powered by the "Smart Matrix Engine." This engine evaluates the current price in a multi-layer market structure context (Static Volume Zones + Dynamic Channels + Volume Metrics).:

A. S-State (Static): Where is the price relative to the Volume S/R zones?
B. D-State (Dynamic): Where is the price relative to the Trend Channels?

How to read the Matrix Map:
The dashboard displays a 5x5 grid representing 25 possible market scenarios.
- Rows (S1-S5): Represent the Static State (S1=Breakout, S3=Mid-Range, S5=Breakdown).
- Columns (D1-D5): Represent the Dynamic State (D1=Overextended Up, D3=Neutral, D5=Overextended Down).
- Active Cell: Marked with a dot, indicating the specific intersection of price action and market structure.

4. Matrix Interpretations (The 25 Scenarios)
Below is the detailed logic for every possible state displayed on the dashboard, explaining the Title, Bias, and actionable Signal.

Section I: S1 - Static Breakout (Price > Static Resistance)
The price has cleared the static volume resistance zone.


- S1 / D1: HYPER EXTENSION
Bias: Extreme Bullish
Signal: Caution: Exhaustion Risk. Trail stops tight.

- S1 / D2: RESISTANCE CLASH
Bias: Bullish
Signal: Breakout confirmed but facing immediate dynamic resistance.

- S1 / D3: CHANNEL BREAKOUT
Bias: Strong Bullish
Signal: Ideal Trend Continuation. Look to buy dips.

- S1 / D4: SMART PULLBACK
Bias: Bullish (Pullback)
Signal: A pullback occurring after a breakout. Strong buy opportunity.

- S1 / D5: CONFLICT (DIV)
Bias: Conflict/Reversal
Signal: Major Divergence. Static breakout is failing against dynamic structure. High Risk.

Section II: S2 - Inside Static Resistance
The price is currently testing the overhead resistance zone.


- S2 / D1: WEAK SPIKE
Bias: Neutral/Bullish
Signal: Testing resistance, but short-term overextended.

- S2 / D2: IRON FORTRESS (R)
Bias: Rejection Risk
Signal: Double Resistance (Static + Dynamic). High probability of rejection.

- S2 / D3: TESTING RES
Bias: Neutral
Signal: Consolidating at resistance. Wait for a clear break or rejection.

- S2 / D4: COMPRESSION (UP)
Bias: Conflict (Squeeze)
Signal: Squeezed between Static Resistance and Dynamic Support. Volatility imminent.

- S2 / D5: RES vs DOWN-TREND
Bias: Bearish
Signal: Strong downtrend meeting static resistance. Potential Short entry.

Section III: S3 - Mid-Range
The price is floating between significant Static Support and Resistance.


- S3 / D1: OVERBOUGHT RANGE
Bias: Rejection Risk (OB)
Signal: Overextended within the range. Potential fade (short).

- S3 / D2: RANGE HIGH LIMIT
Bias: Neutral/Bearish
Signal: At the top of the dynamic channel. Look for rejection signs.

- S3 / D3: NEUTRAL / CHOPPY
Bias: Neutral
Signal: Dead Center. Low probability environment. Avoid trading.

- S3 / D4: RANGE DIP BUY
Bias: Neutral/Bullish
Signal: At the bottom of the dynamic channel. Look for bounce signs.

- S3 / D5: WEAK RANGE (OS)
Bias: Bounce Risk (OS)
Signal: Oversold within the range. Potential fade (long).

Section IV: S4 - Inside Static Support
The price is currently testing the floor support zone.


- S4 / D1: SUP vs UP-TREND
Bias: Bullish
Signal: Strong uptrend meeting static support. Potential Long entry.

- S4 / D2: COMPRESSION (DN)
Bias: Conflict (Squeeze)
Signal: Squeezed between Static Support and Dynamic Resistance. Volatility imminent.

- S4 / D3: TESTING SUPPORT
Bias: Neutral
Signal: Consolidating at support. Wait for a bounce or breakdown.

- S4 / D4: IRON FLOOR (S)
Bias: Bounce Risk
Signal: Double Support (Static + Dynamic). High probability of a bounce.

- S4 / D5: WEAK DIP
Bias: Neutral/Bearish
Signal: Testing support, but short-term oversold.

Section V: S5 - Static Breakdown (Price < Static Support)
The price has dropped below the static volume support zone.


- S5 / D1: CONFLICT (DIV)
Bias: Conflict/Reversal
Signal: Major Divergence. Static breakdown is failing. High Risk.

- S5 / D2: BEAR PULLBACK
Bias: Bearish (Pullback)
Signal: A pullback occurring after a breakdown. Strong selling opportunity.

- S5 / D3: CHANNEL BREAKDOWN
Bias: Strong Bearish
Signal: Ideal Trend Continuation (Down). Sell rallies.

- S5 / D4: SUPPORT CLASH
Bias: Bearish
Signal: Breakdown confirmed but facing immediate dynamic support.

- S5 / D5: HYPER DROP (VOID)
Bias: Extreme Bearish
Signal: Caution: Climax risk. Trail stops for shorts.

DISCLAIMER & EDUCATIONAL PURPOSE

This indicator is strictly an educational tool designed to visualize complex market structure concepts. Its primary purpose is to help traders "bridge the gap" between academic theory and real-time market behavior by providing a visual representation of support, resistance, and volume dynamics.

Please Note:
1. Not a Trading Strategy: This script is an analytical assistant, not a standalone "Black Box" trading system. It does not generate buy or sell signals that should be followed blindly.
2. No Financial Advice: The data provided by this tool is for informational purposes only. It is not a recommendation to buy or sell any asset.
3. Risk Warning: Trading involves significant risk. Always use your own judgment, perform your own technical analysis, and use proper risk management. Do not use this tool as the sole basis for your trading decisions.
4. Data Precision & Platform Limits: The "Intrabar (Precise)" calculation mode relies on high-resolution historical data to provide exact results. Access to this specific data depth depends entirely on your platform's subscription capabilities. If your plan does not support this level of historical intrabar data, the Precise mode may have limited coverage. In that case, you should switch to "Geometry" mode for a fully populated view.
Notas de prensa
Release Notes: Stability Patch (Critical Fix)

Runtime Error & Data Synchronization Fix

1. The Issue (Symptom)
Users utilizing the "Intrabar (Precise)" calculation method occasionally encountered a critical runtime error: "The requested historical offset is beyond the historical buffer's limit."
This occurred specifically when the script attempted to calculate support/resistance levels on the very first tick of execution or during timeframe changes, before the lower-timeframe (LTF) data had fully buffered.

2. The Diagnosis (Root Cause)
The script's main loop was strictly enforcing the "Universal Lookback Length" (default: 100 bars) for data collection. However, the TradingView engine loads LTF data asynchronously.
- Scenario: The user requests a 100-bar lookback.
- Reality: The engine has only buffered 72 bars of LTF history at that exact millisecond.
- Crash: Accessing index 73 triggered an "Out of Bounds" memory exception.

3. The Solution (Patch)
We implemented a "Dynamic Lookback Clamping" mechanism to synchronize the calculation loop with the available data stream.
- Logic: The script now dynamically calculates an "effective_len" by comparing the user's target length against the actual available history (ltf_cov_bars).
- Implementation: effective_len = math.min(universal_len, ltf_cov_bars)
- Benefit: The indicator now automatically adapts its lookback range based on available data, eliminating crashes while preserving full precision as more history loads naturally.
Notas de prensa
Global Update: Native Multi-Language Support

TradingView is a truly global ecosystem, connecting millions of traders from every corner of the world. We believe that professional technical analysis should be accessible to everyone, regardless of language barriers. To align with this universal spirit, the Dynamic Support and Resistance with Trend Lines (DSRTL) indicator has been upgraded with a robust Localization Engine.

This major update introduces a built-in translation system that dynamically adapts the entire interface—including the Dashboard, Signal Interpretations, and Bias Contexts—into your native language. Whether you are analyzing Matrix Resistance or Channel Breakouts, the insights are now clearer and more immediate.

New Feature: 10 Supported Languages
You can now select your preferred language directly from the settings menu. The script fully supports:

1. English (Default)
2. Türkçe (Turkish)
3. Русский (Russian)
4. Deutsch (German)
5. Français (French)
6. Italiano (Italian)
7. Español (Spanish)
8. العربية (Arabic)
9. فارسی (Persian)
10. עברית (Hebrew)

Technical Note
The translation logic is implemented via an optimized Dictionary Function within the Pine Script code, ensuring that this added versatility comes with zero impact on calculation speed or rendering performance.

A Note to Our Global Community
While we have launched with these 10 major languages to serve a broad audience, we recognize that the TradingView family is vast and diverse. If your native language is not yet included, please accept our sincere apologies. We are committed to making this tool accessible to everyone—feel free to leave a comment below requesting your language, and we will do our best to include it in future updates.
Notas de prensa
DSRTL-ML Script Updates & Changelog

1. Fixed "Table Position" Dropdown Menu:
- Added the missing options parameter to the dash_pos input variable.
- Users can now select all table positions (Top/Middle/Bottom + Left/Center/Right) directly from the settings menu.

2. Removed Visible Unicode Artifacts:
- Deleted the conditional logic that inserted the \u200E (Left-to-Right Mark) character. It was being rendered as literal text in the dashboard for RTL languages instead of functioning as a hidden control character.

3. Re-engineered RTL Text Formatting (Persian/Arabic/Hebrew):
- Implemented a specific logic block for Right-to-Left languages (is_rtl).
- The string concatenation order was reversed and customized to fix visual alignment issues in TradingView.
- New Format: The code now strips the default (R): / (S): prefixes from the translation keys and reconstructs the string as (Symbol) [Price Range] : Label.
- Visual Result: This ensures that for Persian, Arabic, and Hebrew, the text aligns to the Right, the price range sits in the Center, and the (R)/(S) symbol appears on the Left.
Notas de prensa
MAJOR UPDATE - Enhanced Intelligence & Professional Features

This update brings significant improvements to the Dynamic Support and Resistance with Trend Lines (DSRTL) indicator, making it more intelligent, customizable, and user-friendly for professional traders.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📊 NEW FEATURES

1. Smart Alert System
- Intelligent alerts for high-probability trading scenarios
- Two alert modes:
All High-Confidence: Alerts when any scenario reaches your confidence threshold
Specific Scenario: Target exact S/D state combinations (e.g., S1/D3 for Channel Breakout)
- Customizable confidence threshold (50-90%)
- Option to alert only on state changes to reduce noise
- Fully localized alert messages in your selected language

2. Historical Matrix Logger
- Track and review past matrix state changes
- Displays timestamp, S/D state, bias, and confidence for each change
- Configurable history depth (1-20 entries)
- Separate table with flexible positioning
- Perfect for backtesting analysis and pattern recognition

3. Volume Profile Mini-Map
- Visual distribution of volume across price levels
- Identifies POC (Point of Control) - the price level with highest trading activity
- Color-coded buy/sell volume breakdown
- Volume Bias Summary: Instant view of overall bullish/bearish volume sentiment
- POC Position Indicator: Shows if POC is above or below current price
- Current price level highlighting
- Customizable row count and colors

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔧 ENHANCEMENTS

1. Probabilistic Signal Language
- Transformed deterministic signals to probabilistic language
- Added Confidence Percentage (30-80%) for each of the 25 matrix scenarios
- Helps traders understand probability rather than certainty
- Example: "Ideal trend continuation" → "Likely trend continuation (75%)"

2. Dynamic Zone Sensitivity (ATR Factor)
- New input parameter to control S/R zone tolerance
- Range: 0.05 (tight) to 0.50 (wide)
- Default: 0.10 for balanced sensitivity
- Formula: Zone Buffer = ATR × Sensitivity Value
- Allows fine-tuning for different market conditions

3. S/R Time Decay Weighting
- Recent S/R zones now weighted more heavily than older ones
- Configurable decay factor (0.0 - 5.0)
- 0.0 = No decay (equal weight for all zones)
- 0.5 (default) = Moderate decay, recent zones ~2-3x more significant
- Uses exponential decay formula for smooth weighting

4. Flip Logic Stabilization
- New hysteresis buffer prevents rapid S/R flipping in choppy markets
- Configurable stability threshold (0.0 - 2.0 × ATR)
- Reduces false signals during sideways price action
- More stable zone identification without sacrificing responsiveness

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🌐 LANGUAGE SUPPORT

Fully localized in 7 languages:
- English 🇬🇧
- Türkçe 🇹🇷
- Русский 🇷🇺
- Español 🇪🇸
- العربية 🇸🇦
- فارسی 🇮🇷
- עברית 🇮🇱

All new features (alerts, logger, volume profile) include complete translations.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚙️ NEW SETTINGS OVERVIEW

General Configuration:
- Dynamic Zone Sensitivity (0.05-0.50)
- S/R Time Decay Factor (0.0-5.0)
- S/R Flip Stability (0.0-2.0)

Smart Alert System:
- Enable Smart Alerts (on/off)
- Alert Mode (All High-Confidence / Specific Scenario)
- Target S-State (1-5)
- Target D-State (1-5)
- Minimum Confidence % (50-90)
- Alert on State Change Only (on/off)

Historical Matrix Logger:
- Enable State History Log (on/off)
- Max Log Entries (5-20)
- Log Table Position

Volume Profile Mini-Map:
- Enable Volume Profile (on/off)
- Profile Rows (4-12)
- Buy Volume Color
- Sell Volume Color

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📈 CONFIDENCE LEVELS GUIDE

The 25 matrix scenarios now include confidence ratings:

High Confidence (75-80%):
- Iron Fortress (Double Resistance) - 80%
- Iron Floor (Double Support) - 80%
- Channel Breakout/Breakdown - 75%

Good Confidence (65-70%):
- Smart Pullback setups - 70%
- Trend meets Static S/R - 70%
- Compression/Squeeze scenarios - 65%

Moderate Confidence (55-60%):
- Range extremes - 60%
- Mixed signals - 55%

Low Confidence (30-50%):
- Neutral/Testing zones - 45-50%
- Conflict/Divergence - 40%
- Dead Center - 30% (Avoid trading)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

💡 USAGE TIPS

For Day Traders:
- Enable Volume Profile to identify POC for intraday targets
- Set alerts for specific high-probability scenarios (S1/D3, S4/D4, S5/D3)
- Use higher Time Decay (2.0-3.0) for faster adaptation

For Swing Traders:
- Use lower Time Decay (0.5-1.0) for more stable S/R zones
- Enable Logger to track state changes over multiple sessions
- Focus on scenarios with 70%+ confidence

For Volatile Markets:
- Increase Flip Stability (1.0-2.0) to reduce noise
- Increase Dynamic Zone Sensitivity (0.30-0.40)

For Ranging Markets:
- Monitor Dead Center warnings (S3/D3)
- Watch for Compression scenarios (S2/D4, S4/D2)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔔 ALERT SETUP EXAMPLES

Example 1: Channel Breakout Alert
- Alert Mode: Specific Scenario
- Target S-State: 1
- Target D-State: 3

Example 2: Double Support (Iron Floor)
- Alert Mode: Specific Scenario
- Target S-State: 4
- Target D-State: 4

Example 3: All Strong Setups
- Alert Mode: All High-Confidence
- Minimum Confidence: 70%

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📋 CHANGELOG SUMMARY

✅ Added: Smart Alert System with scenario targeting
✅ Added: Historical Matrix Logger with state tracking
✅ Added: Volume Profile Mini-Map with POC detection
✅ Added: Confidence percentages for all 25 scenarios
✅ Added: Probabilistic signal language
✅ Added: Dynamic Zone Sensitivity input
✅ Added: S/R Time Decay weighting system
✅ Added: Flip Logic Stabilization (hysteresis)
✅ Improved: Dashboard information density
✅ Optimized: Code structure for better performance
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Your feedback helps improve this indicator.
Notas de prensa
WHAT IS NEW (Latest Upgrade)

- Unified projection logic: Dynamic Support/Resistance levels now follow the same drawing rule as Static levels and POC — solid up to the current bar, then dashed projection to the right by the user-defined projection length.
- Cleaner dynamic level labeling: Dynamic level prices are shown at the end of the projected offset, matching the same placement style used for Static/POC labels.
- Improved readability: Added a user-controlled font size option for on-chart Static/Dynamic level labels so they’re no longer too small on different screens/timeframes.
- Stability & compatibility refinements: Internal drawing/label routines were adjusted for consistent Pine v6 behavior** and more reliable, tidy rendering.
Notas de prensa
DSRTL-ML — Update Highlights

- Split Lookbacks: Trend lines now use trend_len; core S/R + Matrix/Extremes/VP use universal_len.
- Per-Module Projection: Separate toggles for Matrix, Extremes, Pivot Span, 5-Point Channel, and POC line.
- Extremes Stability Fix: Min-scan can skip the live bar to prevent false “lowest” picks.
- Extreme Candle Markers: New HB/HS/LB/LS labels to spotlight buy/sell extremes.
- Clear Dynamic Naming: “5PT Dyn” and “Pivot Dyn” tags on chart + dashboard (no more unnamed lines).
- Dashboard Upgrade: Levels/System split view + Trend/Global period readouts; Volume
Notas de prensa
DSRTL Update: Universal Compatibility, Precision Controls & Intelligent Label System

This update focuses on three pillars: broader symbol compatibility, finer visual control, and a brand-new intelligent label positioning engine.


1. Universal Symbol Compatibility
Previously, certain symbols without native volume data — such as Commodity CFDs (Oil, Gold, Silver) and Forex pairs — could trigger a runtime crash when loading the indicator. This has been resolved. DSRTL now loads cleanly on every symbol type available on TradingView. On volume-less instruments, the trend lines and dashboard function normally; volume-dependent zones simply remain inactive until volume data is available.


2. Precision Font Size Controls
The old size selector (Tiny / Small / Normal / Large) has been replaced with a numeric font size input measured in typographic points (6–50 pt). This gives you full control over readability, whether you're on a small laptop screen or a multi-monitor trading station.

Two independent size controls are now available:
Dashboard Table Font Size — controls the entire dashboard panel
On-Chart Label Font Size — controls the price level labels (Static R/S, Dynamic, POC) independently from the dashboard

This means you can keep your chart labels compact and clean while running a large, easy-to-read dashboard — or any combination that suits your setup.


3. Human-Readable Table Position Selector
The table position dropdown now displays clear labels like "Top Right", "Middle Center", "Bottom Left" instead of internal code references. A small but meaningful improvement for a smoother settings experience.


4. Intelligent Label Anti-Overlap System (New Feature)
This is the headline feature of this update. When multiple price levels are close together, on-chart labels used to stack on top of each other and become unreadable. The new Anti-Overlap Engine solves this with a three-layer intelligent approach:

Priority Anchoring: POC labels hold their exact price position (highest priority). Static S/R labels have medium priority. Dynamic trend labels are the most flexible and adapt around others.

Confluence Detection (Auto-Merge): When two labels from different systems land at nearly the same price (e.g., Static Resistance and Dynamic Resistance converging), they are automatically merged into a single compound label — visually confirming the confluence zone. Labels from the same system (e.g., top and bottom of a zone) are never merged, preserving zone boundary clarity.

Smart Spacing: After merging, remaining labels are spaced apart using ATR-adaptive minimum distances. Higher-priority labels stay put; lower-priority labels are nudged away just enough to avoid overlap.

Three new settings give you full control:
Enable/Disable the system entirely
Merge Distance — how close two levels must be to trigger a confluence merge
Minimum Spacing — the minimum visual gap between any two labels

The system is fully adaptive — it automatically adjusts to any symbol, timeframe, and volatility condition.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.