OPEN-SOURCE SCRIPT
تم تحديثه Auto Trendlines MTF - Break/Retest [AGPro Series]

Auto Trendlines MTF - Break/Retest [AGPro Series]
🔹 OVERVIEW
Auto Trendlines MTF - Break/Retest is a multi-timeframe trendline visualization engine that automatically detects and draws the most structurally significant trendlines across three complementary scales: Micro (current timeframe), Meso (intermediate pivots), and Mega (HTF weekly/monthly overlay). Instead of relying on a single pivot scan, the engine builds a ranked candidate pool from each scale and selects the lines that best represent the active market structure around current price.
The script is designed as a pure analytical visualization tool — it does not generate trading decisions, forecasts, or directional recommendations. Its purpose is to give the chart a clean, hand-drawn-quality trendline layer that updates automatically as new pivots form.
🎯 UNIQUE EDGE
Most auto-trendline tools scan one timeframe and draw whatever fits. This engine operates differently in four specific ways:
• Three-scale MTF engine. Micro pivots on the current TF, Meso pivots with wider sensitivity, and Mega trendlines derived from Weekly/Monthly HTF pivots are computed independently and rendered together with a visual hierarchy (Mega dominant, Meso intermediate, Micro active).
• Log-space geometry. All trendline math runs in log-price space, so long-dated diagonals on volatile assets (crypto, growth stocks) do not distort visually when the chart is viewed in logarithmic mode.
• Touch-weighted ranking with violation penalty. Each candidate line is scored by touch count, line age, slope sanity, price proximity, and intra-line violations. Weak geometry, over-sloped lines, and frequently violated lines are demoted automatically.
• Q quality score (0–100) and confluence tags (x2/x3). Every drawn line carries a Q score that blends touches, freshness, geometry, relevance, and violations into a single number. Confluence tags surface when a Micro line and a Meso line sit within the same ATR band near price, highlighting multi-scale structure overlap.
🧠 METHODOLOGY
1. Pivot detection. Separate pivot streams are maintained for Micro (tight sensitivity), Meso (wider sensitivity), and Mega (HTF pivots via request.security).
2. Candidate generation. For each scale, the engine pairs anchor pivots with subsequent pivots to form line candidates, discards over-sloped ones, and computes touches, violations, and break status in log space.
3. Ranking. Candidates are scored by a weighted combination of touch count, time span, slope sanity, relevance to current price (distance in ATR), and violation count. The best non-duplicate lines are kept per scale.
4. Clutter guards. A minimum ATR separation rule prevents near-duplicate lines from stacking. Smart Focus hides far-from-price lines in Minimal/Balanced density modes to keep the chart readable.
5. Stability mode. In Locked mode, selected lines persist bar-to-bar and are only replaced when they break or fall out of the candidate pool — reducing visual repainting on lower TFs.
6. Break/Retest detection. Once a line is drawn, the engine tracks close-based breaks (with configurable tolerance) and subsequent retests within a time window, emitting labeled signals on TF ≤ 1D.
⚙️ SIGNALS & ALERTS
Break and retest events are plotted for each scale with short ASCII tags:
• µR / µS = Micro Resistance / Support break
• mR / mS = Meso Resistance / Support break
• MR / MS = Mega Resistance / Support break
• rµ / rm / rM = retest on Micro / Meso / Mega respectively
A dedicated alertcondition is exposed for every break and retest event, plus two aggregate alerts (Any BR, Any RT) for users who prefer a single alert stream. A Min Q filter lets the user suppress low-quality signals.
🛠️ KEY INPUTS
• Profile Mode. Auto by Timeframe or Manual (Clean Trader, Balanced, Analyst, Presentation, Custom).
• Density Override. Minimal, Balanced, or Bold visual density.
• Line Weight Override. UltraThin, Thin, or Normal.
• Labels / Signals / Stability / Broken-line behavior. All individually overridable.
• Mega Overlay. Full (lines + cloud + label), Lines Only, or Off.
• Advanced panels. Micro Engine, Meso Engine, Mega Engine, Ranking, Visuals, and Signals each expose their own fine-tuning controls for experienced users.
• HUD. Position, theme (Classic Gray, Premium Accent, Color Coded, Showcase), and text size.
📘 HOW TO USE
• Add the script to any liquid symbol and start on a 1H or 4H chart.
• Leave Profile Mode on "Auto by Timeframe" for a balanced default that adapts to the active TF.
• Read the HUD in the top-right corner to see the active profile, how many Micro/Meso lines are drawn, whether Mega is active, and current Q scores.
• When a line carries a Q score above ~65 and a Conf tag (x2 or x3) appears nearby, that zone is a multi-scale structural pocket — use it as a planning reference, not as a trade trigger on its own.
• Use the Break/Retest tags for situational awareness around drawn lines; combine with your own confirmation logic before acting.
⚠️ LIMITATIONS & TRANSPARENCY
• Lines are drawn from historical pivots and can only confirm after a pivot is established. The engine avoids repainting in Locked mode but cannot predict future pivots.
• Q scores and confluence tags describe structural quality, not directional probability. A high-Q line can still break.
• Mega lines depend on HTF pivot availability; on very young symbols or thin charts, Mega may fall back to a Macro-pivot source or remain hidden.
• The script is published as Public, Open Source so that every ranking rule, weight, and threshold is fully auditable in the source code.
🛡️ RISK DISCLOSURE
This script is a visualization and analysis tool only. It is not financial advice, not a trading strategy, and not a signal service. No performance claims are made or implied. Past structural behavior of trendlines does not guarantee future behavior. All trading decisions, risk sizing, and execution remain the sole responsibility of the user.
🔹 OVERVIEW
Auto Trendlines MTF - Break/Retest is a multi-timeframe trendline visualization engine that automatically detects and draws the most structurally significant trendlines across three complementary scales: Micro (current timeframe), Meso (intermediate pivots), and Mega (HTF weekly/monthly overlay). Instead of relying on a single pivot scan, the engine builds a ranked candidate pool from each scale and selects the lines that best represent the active market structure around current price.
The script is designed as a pure analytical visualization tool — it does not generate trading decisions, forecasts, or directional recommendations. Its purpose is to give the chart a clean, hand-drawn-quality trendline layer that updates automatically as new pivots form.
🎯 UNIQUE EDGE
Most auto-trendline tools scan one timeframe and draw whatever fits. This engine operates differently in four specific ways:
• Three-scale MTF engine. Micro pivots on the current TF, Meso pivots with wider sensitivity, and Mega trendlines derived from Weekly/Monthly HTF pivots are computed independently and rendered together with a visual hierarchy (Mega dominant, Meso intermediate, Micro active).
• Log-space geometry. All trendline math runs in log-price space, so long-dated diagonals on volatile assets (crypto, growth stocks) do not distort visually when the chart is viewed in logarithmic mode.
• Touch-weighted ranking with violation penalty. Each candidate line is scored by touch count, line age, slope sanity, price proximity, and intra-line violations. Weak geometry, over-sloped lines, and frequently violated lines are demoted automatically.
• Q quality score (0–100) and confluence tags (x2/x3). Every drawn line carries a Q score that blends touches, freshness, geometry, relevance, and violations into a single number. Confluence tags surface when a Micro line and a Meso line sit within the same ATR band near price, highlighting multi-scale structure overlap.
🧠 METHODOLOGY
1. Pivot detection. Separate pivot streams are maintained for Micro (tight sensitivity), Meso (wider sensitivity), and Mega (HTF pivots via request.security).
2. Candidate generation. For each scale, the engine pairs anchor pivots with subsequent pivots to form line candidates, discards over-sloped ones, and computes touches, violations, and break status in log space.
3. Ranking. Candidates are scored by a weighted combination of touch count, time span, slope sanity, relevance to current price (distance in ATR), and violation count. The best non-duplicate lines are kept per scale.
4. Clutter guards. A minimum ATR separation rule prevents near-duplicate lines from stacking. Smart Focus hides far-from-price lines in Minimal/Balanced density modes to keep the chart readable.
5. Stability mode. In Locked mode, selected lines persist bar-to-bar and are only replaced when they break or fall out of the candidate pool — reducing visual repainting on lower TFs.
6. Break/Retest detection. Once a line is drawn, the engine tracks close-based breaks (with configurable tolerance) and subsequent retests within a time window, emitting labeled signals on TF ≤ 1D.
⚙️ SIGNALS & ALERTS
Break and retest events are plotted for each scale with short ASCII tags:
• µR / µS = Micro Resistance / Support break
• mR / mS = Meso Resistance / Support break
• MR / MS = Mega Resistance / Support break
• rµ / rm / rM = retest on Micro / Meso / Mega respectively
A dedicated alertcondition is exposed for every break and retest event, plus two aggregate alerts (Any BR, Any RT) for users who prefer a single alert stream. A Min Q filter lets the user suppress low-quality signals.
🛠️ KEY INPUTS
• Profile Mode. Auto by Timeframe or Manual (Clean Trader, Balanced, Analyst, Presentation, Custom).
• Density Override. Minimal, Balanced, or Bold visual density.
• Line Weight Override. UltraThin, Thin, or Normal.
• Labels / Signals / Stability / Broken-line behavior. All individually overridable.
• Mega Overlay. Full (lines + cloud + label), Lines Only, or Off.
• Advanced panels. Micro Engine, Meso Engine, Mega Engine, Ranking, Visuals, and Signals each expose their own fine-tuning controls for experienced users.
• HUD. Position, theme (Classic Gray, Premium Accent, Color Coded, Showcase), and text size.
📘 HOW TO USE
• Add the script to any liquid symbol and start on a 1H or 4H chart.
• Leave Profile Mode on "Auto by Timeframe" for a balanced default that adapts to the active TF.
• Read the HUD in the top-right corner to see the active profile, how many Micro/Meso lines are drawn, whether Mega is active, and current Q scores.
• When a line carries a Q score above ~65 and a Conf tag (x2 or x3) appears nearby, that zone is a multi-scale structural pocket — use it as a planning reference, not as a trade trigger on its own.
• Use the Break/Retest tags for situational awareness around drawn lines; combine with your own confirmation logic before acting.
⚠️ LIMITATIONS & TRANSPARENCY
• Lines are drawn from historical pivots and can only confirm after a pivot is established. The engine avoids repainting in Locked mode but cannot predict future pivots.
• Q scores and confluence tags describe structural quality, not directional probability. A high-Q line can still break.
• Mega lines depend on HTF pivot availability; on very young symbols or thin charts, Mega may fall back to a Macro-pivot source or remain hidden.
• The script is published as Public, Open Source so that every ranking rule, weight, and threshold is fully auditable in the source code.
🛡️ RISK DISCLOSURE
This script is a visualization and analysis tool only. It is not financial advice, not a trading strategy, and not a signal service. No performance claims are made or implied. Past structural behavior of trendlines does not guarantee future behavior. All trading decisions, risk sizing, and execution remain the sole responsibility of the user.
ملاحظات الأخبار
🔧 UPDATE NOTES - V1.3This update focuses on decision quality, retest planning, visual clarity, and a more selective trendline-break workflow.
The core purpose of the script remains unchanged.
Auto Trendline Break Quality still evaluates confirmed trendline breaks with a 0-100 quality score.
This release improves how the existing 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
------------------------
• Planner-style break state
The script now frames each confirmed trendline break as a decision workflow instead of only a score event.
• Retest pocket visualization
A compact retest pocket is drawn around the broken trendline during the retest window, with the label centered inside the pocket.
• Target and invalidation rails
The latest break can now show a lightweight target reference and invalidation rail so users can read the setup as a structured plan.
• Cleaner action logic
The panel now summarizes Break Side, Break Quality, Retest Risk, Line Strength, and Action.
• More selective confirmation control
A new confirmation mode lets users keep the original close-break behavior or require volume or impulse confirmation.
• Retest failure warning
Failed retests now receive clearer chart language and a dedicated alert condition.
• Screenshot-balanced default preset
The default view now keeps advanced planner layers optional, caps visible break labels, and hides retest markers by default for a cleaner publication screenshot.
• Clearer closed-window action state
When the retest window closes without a valid retest, the panel now uses cleaner decision language instead of a mechanical expired/no-retest state.
• Live active-line extension
The newest unbroken trendline now refreshes forward on each bar, making it easier to watch whether price is approaching a valid trendline break.
• Optional broken-line forward guide
Confirmed broken lines can keep a short forward guide after the break when enabled, while the default screenshot preset keeps this historical extension off.
• Direct latest-line extension
The latest relevant trendline now extends directly into the right-side chart space, making the next possible break area easier to monitor without a separate dashed segment.
------------------------
Visual Improvements
------------------------
• Refined chart readability with compact two-line break labels
• Shortened default label text to reduce visual weight on the chart
• Increased trendline weight slightly so primary structure remains visible on dark TradingView screenshots
• Added a centered retest-pocket label for the active break zone
• Retest pocket, target rail, invalidation rail, and retest markers remain available from inputs but no longer dominate the default chart
• Reduced panel noise by replacing broad statistics with five decision-focused rows
• Kept the AGPro merged blue header row unchanged and publication-standard
• Preserved restrained colors and moderate label density for a cleaner premium chart
------------------------
Interface & Usability
------------------------
• Added Show Retest Pocket control
• Added Show Target / Invalidation Rails control
• Added Ready Break Threshold control
• Added Confirmation Mode control
• Added Break Label Cooldown Bars and Max Retest Markers controls
• Panel location, panel theme, panel visibility, panel font size, and label font size remain configurable
------------------------
Behavior Notes
------------------------
This update does not turn the script into Auto Trendlines MTF.
It remains focused on single-chart trendline break quality, retest planning, and break-state interpretation.
The goal is to improve clarity and usability, not to introduce predictive behavior.
Users should interpret outputs the same way as before, but with stronger structure around retest risk, invalidation context, and next-action state.
------------------------
Limitations Reminder
------------------------
The script remains a rule-based analytical tool.
Trendline pivots are confirmed after their pivot window closes.
Market conditions such as volatility, liquidity, and timeframe differences may affect how breaks, retests, and planner rails 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.
ملاحظات الأخبار
🔧 UPDATE NOTES - V10.2This update focuses on turning Auto Trendlines MTF - Break/Retest into a clearer trendline execution planner with stronger decision-state presentation.
The core purpose of the script remains unchanged.
This release improves how the existing multi-timeframe trendline, break, retest, and quality 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.
Screenshot review note:
The clearest public presentation appears on 4H swing charts, where trendline geometry, retest context, and panel state stay balanced without becoming too sparse or too noisy.
------------------------
What Changed
------------------------
• Added an AGPro decision panel built around the roadmap standard.
The panel now focuses on Active TF, Trendline Side, Break Quality, Retest, and Action.
• Added a clearer next-action state.
The script can now surface BUILDING, WAIT, MONITOR, READY, or INVALIDATED based on break quality and retest behavior.
• Upgraded break/retest interpretation into a planner-style score layer.
The visible score now combines active line quality with retest outcome context instead of showing raw status only.
• Refined active-watch behavior after screenshot review.
When an active trendline exists but quality is not ready, the panel now shows WAIT instead of BUILDING.
• Added premium planner event labels.
READY, INVALIDATED, and optional MONITOR labels can be shown with a configurable label cap to keep the chart readable.
• Added planner-specific alert support.
A consolidated Planner State Change alert marks READY, MONITOR, and INVALIDATED state changes as attention markers while staying inside TradingView plot limits.
------------------------
Visual Improvements
------------------------
• Rebuilt the panel into a compact decision layout with a single merged blue AGPro title row.
• Added AGPro Dark as the default panel theme using the AGPro palette.
• Improved chart readability by replacing overly technical line labels with cleaner R/S and M R/M S labels.
• Kept label density controlled through existing label-size settings and a new maximum planner-label limit.
------------------------
Interface & Usability
------------------------
• Renamed HUD controls into public-facing panel controls.
• Added professional English tooltips for the new panel and planner-label controls.
• Kept panel visibility enabled by default.
• Preserved panel location, theme, panel font size, and label font size customization.
------------------------
Behavior Notes
------------------------
This update does not replace the original multi-timeframe trendline engine.
The goal is to improve clarity, execution readiness, and break/retest interpretation, not to introduce predictive behavior.
Users should interpret outputs as structured attention markers around trendline breaks, retests, and invalidation context.
The script can be used across timeframes, but the default visual balance is best suited for 4H swing trendline review.
------------------------
Limitations Reminder
------------------------
The script remains a rule-based analytical tool.
Market conditions such as volatility, liquidity, timeframe differences, and sudden price gaps may affect how trendlines, breaks, and retests 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.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
Public-free scripts + invite-only AGPro workflows for market analysis, liquidity context, risk planning and execution review.
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
Public-free scripts + invite-only AGPro workflows for market analysis, liquidity context, risk planning and execution review.
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.