Auto Trendlines MTF - Break/Retest [AGPro Series]Auto Trendlines MTF - Break/Retest
🔹 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.
Indicatore Pine Script®






















