PROTECTED SOURCE SCRIPT

IKODO Harmonic Patterns

86
IKODO Harmonic Patterns Pro

OVERVIEW
IKODO Harmonic Patterns Pro is an advanced harmonic pattern detector that automatically identifies four classic harmonic patterns (Gartley, Bat, Butterfly, and Crab) on your chart. Unlike basic harmonic indicators, this tool not only detects completed patterns but also projects potential patterns in formation, providing early warning signals for upcoming trade opportunities. The indicator includes automatic profit targets, stop loss levels, and a real-time statistics dashboard.

This indicator combines pattern recognition with forward-looking projection, allowing traders to prepare for high-probability setups before pattern completion.

HOW IT WORKS
The indicator uses a sophisticated multi-stage detection system:

1. Pivot Detection: Identifies swing highs and lows using configurable lookback period (default: 5 bars)
2. XABCD Structure Analysis: Searches for valid five-point harmonic structures among recent pivots
3. Fibonacci Ratio Validation: Validates patterns against established harmonic ratio requirements with tolerance
4. Pattern Classification: Determines pattern type (Gartley, Bat, Butterfly, or Crab) based on ratios
5. Completed Pattern Drawing: Draws full XABCD structure with labels when pattern completes at point D
6. Potential Pattern Projection: When XAB is completed, projects potential D point for early warning
7. Target Calculation: Automatically calculates three profit targets based on Fibonacci retracements
8. Risk Management: Places stop loss levels based on pattern structure

The tolerance-based matching (default: 15%) allows the indicator to detect real-world patterns that rarely match exact textbook Fibonacci ratios.

KEY FEATURES
Pattern Detection:
- Four harmonic pattern types: Gartley, Bat, Butterfly, Crab
- Automatic XABCD structure identification
- Tolerance-based Fibonacci ratio matching (10-30% configurable)
- Completed pattern detection with full visualization
- Individual pattern type toggles (enable/disable specific patterns)

Unique Projection System:
- Potential pattern detection when XAB structure completes
- Projects expected D point location based on pattern type
- Early warning before pattern completion
- Visual distinction between completed and potential patterns
- Helps traders prepare entries in advance

Automatic Trading Levels:
- Three profit targets (T1: 38.2%, T2: 61.8%, T3: 100% to point C)
- Automatic stop loss placement (1% beyond point D)
- Visual target lines extending 20 bars forward
- Risk/reward visualization for each pattern

Visual Features:
- Complete XABCD structure drawing with solid lines
- Clear X, A, B, C, D point labels
- Bullish patterns in lime green
- Bearish patterns in red
- Potential patterns in orange with dashed lines
- Pattern information labels with emoji indicators
- Real-time statistics table in top-right corner

Statistics Dashboard:
- Gartley pattern count
- Bat pattern count
- Butterfly pattern count
- Crab pattern count
- Total patterns detected
- Active pivot points count

Alert System:
- Real-time alerts when patterns complete
- Includes pattern name, direction, and price
- One alert per bar to prevent spam

SETTINGS
Detection Settings:
- Pivot Length (3-15): Bars for pivot detection. Lower = more pivots, higher = major pivots only
- Fibonacci Tolerance % (10-30): Matching flexibility. Lower = stricter, higher = more patterns
- Lookback Bars (100-300): How far back to search for patterns

Pattern Selection:
- Gartley: Classic 0.618 retracement pattern
- Bat: Deep 0.886 retracement pattern
- Butterfly: Extension pattern (1.272 or 1.618)
- Crab: Extreme extension pattern (1.618)
- Individual toggles for each pattern type

Display Settings:
- Show Pattern Info: Display detailed pattern information labels
- Show Targets: Display T1, T2, T3 profit target levels
- Show Potential Patterns: Display forming patterns (XAB completed, projecting D)

HOW TO USE
The indicator provides both completed patterns (trade immediately) and potential patterns (prepare for trades).

Completed Patterns (Solid Lines):
When a pattern completes at point D:
1. Pattern appears with solid lines in lime (bullish) or red (bearish)
2. X, A, B, C, D points are labeled
3. Pattern info label shows name, direction, and entry price
4. Three target levels (T1, T2, T3) appear as dashed blue lines
5. Stop loss (SL) appears as red dashed line

Entry Strategy:
- BULLISH Pattern: Enter LONG at or near point D
- BEARISH Pattern: Enter SHORT at or near point D
- Place stop loss at the red SL line (1% beyond D)
- Take partial profits at T1 (38.2% retracement to C)
- Take more profits at T2 (61.8% retracement to C)
- Final target at T3 (point C level)

Potential Patterns (Dashed Lines):
When XAB structure completes but D is not yet formed:
1. Pattern appears with dashed orange lines
2. Dotted line projects from C to expected D location
3. "D?" label marks projected D point
4. Pattern info shows "FORMING" status with target D price

Preparation Strategy:
- Monitor potential patterns for early warning
- Set price alerts at projected D levels
- Prepare entry orders in advance
- Wait for actual price confirmation at D before entering
- Potential patterns may or may not complete - use for planning only

Pattern Information Labels:
- Emoji: Visual pattern identifier (Butterfly, Bat, Crab symbols)
- Direction: BULLISH (green triangle up) or BEARISH (red triangle down)
- Entry: Exact price at point D for entry
- Forming: Indicates potential pattern with projected D price

Statistics Table:
Monitor pattern frequency in top-right corner:
- Individual counts per pattern type
- Total patterns detected on current chart
- Pivot points currently stored

HARMONIC PATTERN DETAILS

Gartley Pattern (0.618 Retracement):
- AB retracement: 61.8% of XA
- AD retracement: 78.6% of XA
- Moderate reversal pattern
- Most common harmonic pattern
- Good risk/reward ratio

Bat Pattern (0.886 Retracement):
- AB retracement: 38.2% or 50% of XA
- AD retracement: 88.6% of XA
- Deep retracement pattern
- Strong reversal potential
- Tight stop loss placement

Butterfly Pattern (Extension):
- AB retracement: 78.6% of XA
- AD extension: 127.2% or 161.8% of XA
- Extension beyond X point
- Powerful reversal pattern
- Requires wider stops

Crab Pattern (Extreme Extension):
- AB retracement: 38.2% or 61.8% of XA
- AD extension: 161.8% of XA
- Extreme extension pattern
- Highest profit potential
- Rarest pattern type

RECOMMENDED SETTINGS BY TIMEFRAME

Scalping (1m-5m):
- Pivot Length: 3-5
- Tolerance: 20-25%
- Lookback: 100-150
- Focus: Quick entries, tight targets
- Use T1 and T2 only

Day Trading (15m-1H):
- Pivot Length: 5 (default)
- Tolerance: 15% (default)
- Lookback: 200 (default)
- Focus: Intraday swings
- Use all three targets

Swing Trading (4H-Daily):
- Pivot Length: 7-10
- Tolerance: 10-15%
- Lookback: 250-300
- Focus: Multi-day trends
- Hold for T3, possibly beyond

Position Trading (Daily-Weekly):
- Pivot Length: 10-15
- Tolerance: 10-12%
- Lookback: 300
- Focus: Major reversals
- Target extensions beyond C

RECOMMENDED INSTRUMENTS
Best Performance:
- Forex major pairs (EURUSD, GBPUSD, USDJPY) - Clear harmonic structures
- Cryptocurrency (BTC, ETH) - High volatility creates patterns
- Stock indices (SPY, QQQ, ES, NQ) - Institutional participation
- Liquid commodities (GOLD, SILVER, OIL) - Trending behavior
- Large-cap stocks (AAPL, MSFT, TSLA) - Good volume

Avoid:
- Low-volume altcoins (erratic pivots)
- Penny stocks (unreliable patterns)
- Illiquid options (wide spreads)
- Newly listed assets (insufficient history)

BEST PRACTICES
1. Confirmation is Key:
- Wait for point D to actually form before entering
- Potential patterns are projections, not guarantees
- Use additional confirmation (volume, candlestick patterns)
- Don't enter blindly at projected D points

2. Risk Management:
- Always use the provided stop loss level
- Risk maximum 1-2% per trade
- Position size based on stop distance
- SL is 1% beyond D - adjust if needed for your risk tolerance

3. Target Management:
- Take partial profits at each target level
- Example: 50% at T1, 30% at T2, 20% at T3
- Move stop to breakeven after T1 hit
- Consider holding beyond T3 if momentum strong

4. Pattern Quality:
- Clearer patterns (tighter Fibonacci ratios) = higher probability
- Patterns on higher timeframes more reliable
- Patterns with volume confirmation better
- Avoid patterns with choppy, overlapping pivots

5. Market Context:
- Bullish patterns more reliable in uptrends
- Bearish patterns more reliable in downtrends
- Counter-trend patterns need strong confirmation
- Avoid patterns during major news events

6. Use the Projection Feature:
- Set alerts at projected D levels
- Prepare trading plan in advance
- Monitor price action as it approaches projected D
- Don't assume potential pattern will complete

LIMITATIONS
Technical Limitations:
- Patterns are drawn retrospectively after pivot confirmation
- Pivot lookback creates detection delay (minimum 5 bars after D forms)
- Tolerance-based matching means not all patterns are perfect textbook examples
- Maximum 50 pivots stored - very old patterns may be missed
- Potential pattern projections are estimates, not guarantees
- D point projections assume XA ratio only, don't account for CD/BC ratios

Market Limitations:
- False breakouts can invalidate patterns quickly
- Choppy markets produce many overlapping patterns
- Gap markets may complete patterns at unexpected prices
- News events can cause patterns to fail instantly
- Not all patterns reach all three targets
- Some patterns break stop loss before reversing

Usage Limitations:
- Requires understanding of harmonic pattern theory
- Not suitable for complete beginners
- Should combine with other analysis (volume, support/resistance)
- Pattern recognition is not predictive of future results
- Potential patterns often don't complete
- Statistics table resets on chart reload (not persistent)

ORIGINALITY
This indicator implements advanced harmonic pattern detection with unique forward-looking projection capabilities.

Core Innovation:
- Potential pattern projection when XAB completes (early warning system)
- Automatic profit target calculation with three levels
- Built-in stop loss placement based on pattern structure
- Real-time statistics dashboard for pattern tracking
- Visual distinction between completed and forming patterns

Trading Edge:
The potential pattern feature sets this indicator apart from standard harmonic detectors. By projecting expected D points when XAB structure completes, traders can:
- Prepare entries before pattern completion
- Set limit orders at projected levels
- Plan risk management in advance
- Avoid chasing completed patterns
- Identify high-probability zones early

Technical Implementation:
- Efficient pivot storage system (maximum 50 pivots, auto-cleanup)
- Dual-loop pattern detection (completed + potential)
- Dynamic projection calculation based on Fibonacci extensions
- Automatic target and stop loss generation
- Clean visual hierarchy (solid = completed, dashed = potential)
- Performance-optimized for real-time detection

Educational Value:
- Shows complete XABCD structure clearly
- Labels all five points explicitly
- Displays pattern name and direction
- Visual targets teach Fibonacci profit taking
- Statistics help traders understand pattern frequency
- Potential patterns teach pattern formation process

WHY THIS IS UNIQUE (NOT JUST ANOTHER HARMONIC INDICATOR)
While harmonic patterns are well-established concepts, this implementation provides unique value through its projection system and integrated trading tools.

Differentiation from Standard Harmonic Indicators:
Most harmonic indicators on TradingView:
- Only show completed patterns (after price already moved)
- No profit target calculation
- No stop loss guidance
- No early warning system
- Just draw lines without trading context
- No statistics or pattern tracking

This IKODO Harmonic Patterns Pro provides:
- POTENTIAL PATTERN PROJECTION (unique early warning feature)
- AUTOMATIC TARGET LEVELS (T1, T2, T3 calculated for every pattern)
- BUILT-IN STOP LOSS (risk management included)
- DUAL DETECTION SYSTEM (completed + forming patterns)
- STATISTICS DASHBOARD (pattern frequency tracking)
- COMPLETE TRADING CONTEXT (entry, targets, stops all visualized)

WHY POTENTIAL PATTERN PROJECTION IS UNIQUE:
Standard harmonic indicators wait for point D to form before drawing anything. By that time, price has already moved significantly. This indicator identifies when XAB structure is complete and projects where D should form based on the pattern type.

Benefits of Projection System:
1. Early Warning: Know high-probability reversal zones before price arrives
2. Preparation Time: Set limit orders and alerts in advance
3. Better Entries: Enter at projected D instead of chasing after completion
4. Risk Planning: Calculate position size before pattern completes
5. Market Awareness: Understand potential reversal zones forming

How Projection Works:
- Monitors for completed XAB structures in real-time
- Calculates AB/XA ratio to determine likely pattern type
- Projects D point using appropriate Fibonacci extension (0.786 for Gartley, 0.886 for Bat, etc.)
- Draws dashed orange lines from XA to projected D
- Updates projection as new XAB structures form
- Converts to solid line completed pattern when actual D forms

This forward-looking capability transforms harmonic trading from reactive (waiting for completion) to proactive (preparing for completion).

AUTOMATIC TARGET AND STOP LOSS SYSTEM:
Many harmonic indicators show patterns but leave traders guessing about profit targets and stops. This indicator calculates and displays:

Target Calculation Logic:
- T1 (First Target): 38.2% Fibonacci retracement from D to C
- T2 (Second Target): 61.8% Fibonacci retracement from D to C
- T3 (Final Target): 100% retracement to point C level
- Extensions: Visual lines extend 20 bars forward for clarity

Stop Loss Calculation:
- Placed 1% beyond point D (below D for bullish, above D for bearish)
- Provides cushion for minor price fluctuations
- Invalidates pattern if price moves against setup
- Conservative placement suitable for most strategies

This integrated risk management system makes the indicator actionable for traders without requiring manual Fibonacci tool usage or calculation.

VISUAL HIERARCHY AND CLARITY:
Clear visual communication separates completed patterns from potential patterns:

Completed Patterns:
- Solid bright lines (lime green = bullish, red = bearish)
- All five points labeled (X, A, B, C, D)
- Pattern info label with emoji, direction, entry price
- Target levels in blue with T1, T2, T3 labels
- Stop loss in red with SL label
- Professional appearance, easy to identify

Potential Patterns:
- Dashed orange lines (distinct from completed)
- Dotted projection line from C to expected D
- "D?" label at projected point
- "FORMING" status in info label
- Less prominent to avoid confusion
- Clear visual indication this is projection, not fact

This hierarchy prevents traders from confusing projections with actual patterns, maintaining realistic expectations.

STATISTICS AND PATTERN TRACKING:
The real-time statistics table provides valuable pattern frequency data:
- Track which patterns occur most often on your instrument
- Understand pattern distribution across timeframes
- Monitor total pattern count for backtesting context
- See active pivot count for detection sensitivity
- Helps traders specialize in specific pattern types
- Data-driven approach to pattern trading

SIMPLIFIED SETTINGS FOR USABILITY:
Unlike overly complicated harmonic indicators with dozens of inputs, this indicator focuses on three core settings:
1. Pivot Length: Controls pivot sensitivity (major vs minor pivots)
2. Fibonacci Tolerance: Controls pattern strictness (strict vs flexible)
3. Lookback Bars: Controls detection range (recent vs historical)

This simplicity makes the indicator accessible to traders learning harmonic patterns while providing enough flexibility for advanced users.

COMPARISON TO OTHER HARMONIC INDICATORS:
Search TradingView for "harmonic patterns" and you'll find indicators that only show completed patterns with no targets, no stops, no projection system, overly complicated settings, poor visual clarity, or frequent repainting.

This indicator provides a complete harmonic trading system with early warning projection, automatic trading levels, clean professional visuals, simplified intuitive settings, and zero repainting (confirmed pivots only).

The originality lies not in inventing harmonic patterns (they're well-established), but in creating a COMPLETE TRADING TOOL with projection capability, integrated risk management, and professional execution that solves the limitations of basic harmonic indicators.

DISCLAIMER
This indicator is for educational and informational purposes only. It is NOT financial advice, investment advice, or a recommendation to buy or sell any asset. Harmonic patterns do not guarantee profitable trades. Projected potential patterns are estimates and may not complete. Price may not reach all target levels. Stop losses can be hit before reversal occurs. Past pattern performance does not indicate future results. Always use proper risk management, employ stop losses, never invest more than you can afford to lose, and do your own research (DYOR). Consult a licensed financial advisor before making investment decisions.

RISK MANAGEMENT
Essential Risk Rules:
- Always use the provided stop loss levels
- Risk maximum 1-2% of account per trade
- Position size based on stop distance to D point
- Never enter potential patterns without price confirmation
- Not all patterns reach all three targets
- Take partial profits at each target level
- Move stop to breakeven after T1 is hit
- Don't trade patterns during major news events

Position Management:
- Enter at or near point D completion
- Use limit orders at projected D for potential patterns
- Scale out: 50% at T1, 30% at T2, 20% at T3
- Trail stops in strong moves beyond T3
- Exit immediately if stop loss is hit
- Don't average down if pattern fails

MARKET CONDITIONS
Works Best In:
- Trending markets with clear pivot structures
- Assets respecting Fibonacci levels
- After strong impulsive moves creating clear XA legs
- Liquid instruments with tight spreads
- Markets with institutional participation

Works Poorly In:
- Extremely choppy, range-bound conditions
- Low-liquidity instruments with erratic price action
- During unexpected major news events
- Markets with frequent gaps (overnight, crypto futures)
- Newly listed assets with limited price history

VERSION HISTORY
v1.0 - January 26, 2026
- Initial release
- Four harmonic pattern types (Gartley, Bat, Butterfly, Crab)
- Potential pattern projection system (XAB-based D projection)
- Automatic profit targets (T1, T2, T3)
- Built-in stop loss placement
- Real-time statistics dashboard
- Tolerance-based Fibonacci matching
- Completed and forming pattern visualization
- Pattern-specific alert system
- Individual pattern toggles

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.