OPEN-SOURCE SCRIPT

Smart Adaptive Double Patterns [The_lurker]

1 004
Smart Adaptive Double Patterns

This is an advanced technical indicator that combines two of the strongest and most renowned classical price reversal patterns:

✅ Double Bottom Pattern — a bullish reversal pattern that forms after a downtrend
✅ Double Top Pattern — a bearish reversal pattern that forms after an uptrend

The indicator does not merely detect patterns — it provides a fully integrated, intelligent system that includes:

✅ Precise quality scoring for each pattern using 5 technical criteria
✅ Automatic price target calculation at three levels (Conservative, Balanced, Aggressive)
✅ Multi-layer dynamic filtering to avoid false signals
✅ Live pattern tracking from formation to target achievement or failure
✅ Comprehensive alert system covering all possible trading scenarios

🎯 Why Is This Indicator Unique?

1️⃣ High Detection Accuracy
Unlike traditional indicators that rely on simple rules, this one applies 5 strict structural conditions to confirm pattern validity:

A clear trend must precede the pattern
High symmetry between the two bottoms or two tops
No break of critical price levels during formation
Logical spacing between key points
Technical confirmation from ADX, ATR, and Volume

2️⃣ Advanced Quality Scoring System
Each pattern is scored out of 100 based on 5 weighted criteria:

Symmetry (30%): How closely the two bottoms or tops match
Trend Strength (20%): Strength of the prior trend
Volume Behavior (20%): Trading activity at critical points
Pattern Depth (15%): Vertical distance between neckline and bottom/top
Structural Integrity (15%): Full compliance with structural rules
3️⃣ Smart Target Management

Separate targets for bullish (Double Bottom) and bearish (Double Top) patterns
Separate projections for success and failure cases
Multiple options: Conservative (0.618) / Balanced (1.0) / Aggressive (1.618)
Live tracking with dynamic moving lines

4️⃣ Professional Failure Handling
Failed patterns are not ignored — they are turned into counter-trend opportunities:

Failed Double Bottom → triggers a bearish signal with downside targets
Failed Double Top → triggers a bullish signal with upside targets
Automatic color change for clear visual distinction

5️⃣ Full Customization Flexibility

Enable/disable each pattern independently
22+ adjustable settings
Unique colors for each pattern and quality level
Full bilingual support (Arabic / English)

📐 Pattern Details

🟦 Double Bottom Pattern

syot kilat

Sequence of points:

🔹 Point 1: Peak marking the start of a strong downtrend
🔹 Point 2 (Bottom 1): First low — first key bounce
🔹 Point 3: Intermediate high — forms the neckline (resistance)
🔹 Point 4 (Bottom 2): Second low — should closely match Bottom 1
🔹 Point 5: Breakout point — pattern confirmation

Mandatory Conditions:

✅ Clear downtrend before Point 2
✅ Bottoms 2 & 4 nearly identical (≤1.5% difference by default)
✅ Point 3 higher than both bottoms
✅ Neither bottom is broken during formation
✅ Sufficient time between points (≥10 candles by default)

✅ Success Scenario
→ Price breaks above the neckline (Point 3)
→ Point 5 is plotted at breakout candle
→ Dashed vertical line drawn from Point 5 to target
→ Horizontal dashed line tracks price toward target
→ Dashboard shows: Pattern Type | Quality | Rating | Target | Status
→ When target hits: line turns green + ✅ appears

🎯 Target Calculation
Pattern Height = Point 3 − Point 4
• Conservative: Point 3 + (Height × 0.618 × Quality Factor)
• Balanced: Point 3 + (Height × 1.0 × Quality Factor)
• Aggressive: Point 3 + (Height × 1.618 × Quality Factor)

❌ Failure Scenario

syot kilat

→ Price breaks below both Bottom 1 or Bottom 2 before neckline breakout

Visual Changes:

All lines turn red
Red ✖ appears at breakdown candle
Neckline stops expanding
Red dashed vertical line from breakdown point to bearish target
Red horizontal tracking line follows price
Dashboard updates to:
⚠ Failed Bottom – Bearish
→ Shows new bearish target
→ Indicates target mode for failure case
→ Status: Bearish Reversal
→ Fully red display

🟥 Double Top Pattern

Sequence of points:

🔹 Point 1: Trough marking the start of a strong uptrend
🔹 Point 2 (Top 1): First peak — first key resistance
🔹 Point 3: Intermediate low — forms the neckline (support)
🔹 Point 4 (Top 2): Second peak — should closely match Top 1
🔹 Point 5: Breakdown point — pattern confirmation

Mandatory Conditions:
syot kilat

✅ Clear uptrend before Point 2
✅ Tops 2 & 4 nearly identical (≤1.5% difference by default)
✅ Point 3 lower than both tops
✅ Neither top is breached during formation
✅ Sufficient time between points (≥10 candles by default)

✅ Success Scenario
→ Price breaks below the neckline (Point 3)
→ Point 5 is plotted at breakdown candle
→ Dashed vertical line drawn to target
→ Horizontal tracking line moves with price
→ Dashboard updates accordingly
→ Green line + ✅ on hit

🎯 Target Calculation
Pattern Height = Point 4 − Point 3
• Conservative: Point 3 − (Height × 0.618 × Quality Factor)
• Balanced: Point 3 − (Height × 1.0 × Quality Factor)
• Aggressive: Point 3 − (Height × 1.618 × Quality Factor)

❌ Failure Scenario
syot kilat

→ Price breaks above either Top 1 or Top 2 before neckline breakdown

Visual Changes:

All lines turn cyan (light blue)
Cyan ✖ appears at breakout candle
Neckline stops expanding
Cyan dashed vertical line to bullish target
Cyan horizontal tracking line follows price
Dashboard updates to:
⚠ Failed Top – Bullish
→ Shows new bullish target
→ Indicates target mode for failure case
→ Status: Bullish Reversal
→ Fully cyan display

🎯 Upside Target (after Double Top failure)
Max Top = max(Point 2, Point 4)
Height = Max Top − Point 3
• Conservative: Max Top + (Height × 0.618)
• Balanced: Max Top + (Height × 1.0)
• Aggressive: Max Top + (Height × 1.618)

📊 Quality Scoring System (0–100)

1️⃣ Symmetry (30%)
Measures price match between the two bottoms or two tops.

High score (25–30): Near-perfect symmetry → very strong pattern
Medium (15–24): Good match → reliable signal
Low (5–14): Weak symmetry → use caution
Zero: No symmetry → invalid pattern
2️⃣ Trend Strength (20%)
Uses ADX and DI indicators.

20 pts: Strong trend confirmed (e.g., ADX ≥ 20 + correct DI alignment)
10 pts: Trend filter disabled
6 pts: Weak or sideways trend
3️⃣ Volume Behavior (20%)
Declining volume on second touch is a positive sign (shows exhaustion).

15–20 pts: Clear volume drop → strong signal
10 pts: Neutral volume
6 pts: Rising volume → higher risk of continuation
4️⃣ Pattern Depth (15%)
Deeper patterns = stronger reversals.

12–15 pts: Deep → high reversal power
8–11 pts: Medium → acceptable
<8 pts: Shallow → weak signal
5️⃣ Structural Integrity (15%)
Checks logical structure (e.g., Point 1 > Point 3 in Double Bottom).

12–15 pts: Ideal structure
8–11 pts: Minor flaws
<8 pts: Poor setup
📈 Final Quality Rating & Colors

• 85–100 → ⭐ Excellent
 → Double Bottom: Cyan #00BCD4
 → Double Top: Light Red #FF5252

• 75–84 → ✨ Very Good
• 65–74 → ✓ Good
• 60–64 → ○ Acceptable
 → All use Amber #FFC107

• <60 → ❌ Rejected (not shown)
 → Gray #9E9E9E

🔧 Dynamic Filters

1️⃣ ATR Filter (Volatility Check)
Rejects patterns in abnormally high volatility periods.
→ If current ATR > 1.8 × 50-period ATR MA → pattern rejected
✅ Recommended for crypto, small caps
❌ Optional for calm markets (gold, bonds)

2️⃣ ADX Filter (Trend Confirmation)
Ensures a real trend exists before the pattern.
→ If ADX < 14 (70% of default 20) → pattern rejected
✅ Strongly recommended (keep ON)

3️⃣ Volume Filter (Behavior Validation)
Not used to reject patterns, but strongly affects quality score.
✅ Best for liquid markets (Forex majors, large stocks)
❌ Optional for illiquid assets

⚙️ Key Settings Explained

🔘 General Settings
• Language: Arabic / English
• Show Previous Patterns: Yes / No
 → “No” keeps chart clean; “Yes” for historical review

🔘 Pattern Selection
• Enable Double Bottom: ✅ / ❌
• Enable Double Top: ✅ / ❌
→ Use combinations:
 ✅✅ → Full reversal scanning
 ✅❌ → Long setups only
 ❌✅ → Short setups only
 ❌❌ → Indicator OFF

🔘 Detection Parameters
• Pivots Left (1–20): Higher = more reliable, fewer patterns
• Pivots Right (1–20): Lower = faster signals
• Min Width (5–100): Min candles between Bottom/Top 1 & 2
• Tolerance % (0.1%–5%): Max allowed price difference
• Min Arm (5–50): Min candles between pivot & neckline
• Min Trend (5–50): Min candles in prior trend
• Trend Lookback (50–500): How far back to detect trend start
• Extension Multiplier (1.0–5.0): How long to wait for breakout

🔘 Quality Settings
• Min Quality Score (0–100):
 → Conservative: 75–85
 → Balanced: 60–70
 → Flexible: 50–55
• Custom Weights: Adjust based on market (e.g., increase Volume weight in Forex)

🔘 Target Settings
• Bottom Bullish Target: Conservative / Balanced / Aggressive
• Bottom Bearish Target: (used on failure)
• Top Bearish Target: Conservative / Balanced / Aggressive
• Top Bullish Target: (used on failure)

🔘 Visual Settings
• Label Size: Small / Normal / Large / Huge
• Pattern Colors: Fully customizable
• Table: Show/Hide + Size (Small/Normal/Large) + Position (Top-Right / Top-Left / Bottom-Right / Bottom-Left)
• Fill Transparency: 70%–95% (default: 85%)

🔔 Alert System (8 Independent Alerts)

📌 Double Bottom Alerts

Bullish Breakout → “Double Bottom Breakout – Bullish!”
Bullish Target Hit → “Bullish Target Achieved!”
Failure (Bearish) → “Double Bottom Failed – Bearish!”
Bearish Target Hit → “Bearish Target Achieved (Failure)!”
📌 Double Top Alerts

Bearish Breakdown → “Double Top Breakdown – Bearish!”
Bearish Target Hit → “Bearish Target Achieved!”
Failure (Bullish) → “Double Top Failed – Bullish!”
Bullish Target Hit → “Bullish Target Achieved (Failure)!”
Each alert can be enabled/disabled independently and supports pop-ups, emails, or webhooks.


⚠️ Disclaimer:
This indicator is for educational and analytical purposes only. It does not constitute financial, investment, or trading advice. Use it in conjunction with your own strategy and risk management. Neither TradingView nor the developer is liable for any financial decisions or losses.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.