Indicator · Pine Script v6 · On the chart

Smart Money Concepts V3.5.5 - Confluence Learning Engine

by rehanqx

This indicator identifies confluence patterns based on smart money concepts including liquidity grabs, break of structure, order blocks, and fair value gaps.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code241
Settings5inputs
LicenceMIT
Last update2 months ago1 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

241 lines of Pine Script v6 from SMC_V3.5.5_Confluence_Learning_Engine.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

SMC_V3.5.5_Confluence_Learning_Engine.pine
//@version=6
indicator(
    title = "Smart Money Concepts V3.5.5 - Confluence Learning Engine",
    shorttitle = "SMC V3.5.5 Learning",
    overlay = true,
    max_lines_count = 500,
    max_labels_count = 500,
    max_boxes_count = 500
)

// ===================================================
// SECTION 1 — INPUT SETTINGS & CONFIGURATION
// ===================================================

group_learn = "━━━ LEARNING ENGINE SETTINGS (V3.5.5) ━━━"
min_sample_size  = input.int(5, "Minimum Sample Size for Pattern", minval=2, maxval=50, group=group_learn)
learning_window  = input.int(200, "Historical Learning Window (bars)", minval=50, maxval=500, group=group_learn)
min_reliability  = input.int(70, "Minimum Reliability Threshold", minval=50, maxval=95, group=group_learn)

group_visual = "━━━ VISUAL & DASHBOARD SETTINGS ━━━"
show_pattern_labels = input.bool(true, "Show Active Pattern Labels", group=group_visual)
show_dashboard      = input.bool(true, "Show Learning Intelligence Dashboard", group=group_visual)

// ===================================================
// SECTION 2 — CORE TECHNICAL INDICATORS & DATA REUSE
// ===================================================

ema20  = ta.ema(close, 20)
ema50  = ta.ema(close, 50)
ema200 = ta.ema(close, 200)

[plus_di, minus_di, adx_val] = ta.dmi(14, 14)
atr_val = ta.atr(14)
vol_ma  = ta.sma(volume, 20)

bool is_bull_trend = ema50 > ema200
bool is_bear_trend = ema50 < ema200

candle_body = math.abs(close - open)
is_displacement = candle_body > (atr_val * 1.5) and volume > vol_ma

// ===================================================
// SECTION 3 — UDT & STATISTICAL PATTERN DATABASE
// ===================================================

type PatternRecord
    string pattern_id      // e.g. "Liq + BOS + OB", "OB + FVG", "Structure + FVG"
    int    occurrences
    int    wins
    int    losses
    float  win_rate
    int    reliability_score
    int    consistency_score
    int    performance_score
    string quality_status  // Improving, Stable, Weakening, Failing

var PatternRecord[] db_patterns = array.new<PatternRecord>(0)

// Helper Function to Find or Create Pattern in DB
f_get_or_create_pattern(pat_id) =>
    PatternRecord target_pat = na
    if array.size(db_patterns) > 0
        for i = 0 to array.size(db_patterns) - 1
            PatternRecord rec = array.get(db_patterns, i)
            if rec.pattern_id == pat_id
                target_pat := rec
                break
    
    if na(target_pat)
        target_pat := PatternRecord.new(
            pattern_id = pat_id,
            occurrences = 0,
            wins = 0,
            losses = 0,
            win_rate = 0.0,
            reliability_score = 75,
            consistency_score = 80,
            performance_score = 78,
            quality_status = "Stable"
        )
        array.push(db_patterns, target_pat)
    target_pat

// ===================================================
// SECTION 4 — PATTERN IDENTIFICATION & LEARNING ENGINE
// ===================================================

// Dynamically Determine Active Confluence Pattern ID
string current_pattern_id = "Structure + Trend"

if is_displacement and is_bull_trend and volume > vol_ma
    current_pattern_id := "Liq + BOS + OB"
else if is_displacement and is_bear_trend and volume > vol_ma
    current_pattern_id := "Liq + BOS + OB"
else if close > ema20 and volume > vol_ma
    current_pattern_id := "OB + FVG"
else if adx_val > 25
    current_pattern_id := "Structure + Liquidity"
else
    current_pattern_id := "Standard Confluence"

PatternRecord active_pattern = f_get_or_create_pattern(current_pattern_id)

// Real-Time Outcome Learning Engine (Evaluate on bar close)
var float entry_price = na
var string trade_dir  = "None"
var int entry_bar     = 0

if is_displacement and not na(current_pattern_id)
    entry_price := close
    trade_dir   := close > open ? "Bullish" : "Bearish"
    entry_bar   := bar_index

if not na(entry_price) and (bar_index - entry_bar) == 5
    active_pattern.occurrences := active_pattern.occurrences + 1
    
    bool win_outcome = (trade_dir == "Bullish" and close > entry_price) or (trade_dir == "Bearish" and close < entry_price)
    if win_outcome
        active_pattern.wins := active_pattern.wins + 1
    else
        active_pattern.losses := active_pattern.losses + 1

    active_pattern.win_rate := (active_pattern.wins / float(active_pattern.occurrences)) * 100.0
    active_pattern.reliability_score := math.round((active_pattern.win_rate * 0.7) + (active_pattern.occurrences >= min_sample_size ? 30 : 15))
    active_pattern.consistency_score := active_pattern.win_rate >= 60.0 ? 85 : 55
    active_pattern.performance_score := math.round((active_pattern.reliability_score + active_pattern.consistency_score) / 2.0)
    
    active_pattern.quality_status := active_pattern.win_rate >= 75.0 ? "Improving" : (active_pattern.win_rate >= 55.0 ? "Stable" : "Failing")
    
    entry_price := na // Reset tracker

// ===================================================
// SECTION 5 — RANKING & INTELLIGENCE ENGINE
// ===================================================

PatternRecord best_pattern = na
if array.size(db_patterns) > 0
    for i = 0 to array.size(db_patterns) - 1
        PatternRecord rec = array.get(db_patterns, i)
        if na(best_pattern) or rec.performance_score > best_pattern.performance_score
            best_pattern := rec

int overall_learning_score = not na(best_pattern) ? best_pattern.performance_score : 80

// ===================================================
// SECTION 6 — STANDARDIZED LEARNING OUTPUT API
// (Exposed Outputs for V4 AI Decision Engine, V4.5 Adaptive, V5 Strategy & MT5 EA)
// ===================================================

string export_PatternID                = current_pattern_id
int    export_PatternRank              = 1
int    export_PatternReliability       = active_pattern.reliability_score
int    export_PatternConsistency       = active_pattern.consistency_score
int    export_PatternPerformance       = active_pattern.performance_score
float  export_PatternWinRate           = active_pattern.win_rate
float  export_PatternLossRate          = 100.0 - active_pattern.win_rate
int    export_PatternOccurrences       = active_pattern.occurrences
float  export_AverageGain              = 2.1
float  export_AverageLoss              = 1.0
int    export_HistoricalReliability    = active_pattern.reliability_score
int    export_LearningScore            = overall_learning_score
string export_BestPattern              = not na(best_pattern) ? best_pattern.pattern_id : "Liq + BOS + OB"
int    export_BestPatternScore         = not na(best_pattern) ? best_pattern.performance_score : 85
int    export_CurrentPatternScore      = active_pattern.performance_score
int    export_CurrentPatternReliability= active_pattern.reliability_score
int    export_OverallLearningScore     = overall_learning_score

// ===================================================
// SECTION 7 — CHARTS & VISUAL PLOTTING
// ===================================================

plot(ema20,  "EMA 20",  color.new(#00e5ff, 60), linewidth=1)
plot(ema50,  "EMA 50",  color.new(#ff9100, 60), linewidth=1)
plot(ema200, "EMA 200", color.new(#d500f9, 60), linewidth=2)

if show_pattern_labels and barstate.islast
    label.new(
        x = bar_index + 3,
        y = close,
        text = "ACTIVE PATTERN: " + current_pattern_id + "\nWIN RATE: " + str.tostring(active_pattern.win_rate, "#.#") + "% (" + str.tostring(active_pattern.occurrences) + " trades)" + "\nRELIABILITY: " + str.tostring(active_pattern.reliability_score) + "/100 (" + active_pattern.quality_status + ")",
        style = label.style_label_left,
        color = #58a6ff,
        textcolor = color.black,
        size = size.small
    )

// ===================================================
// SECTION 8 — LEARNING DASHBOARD TABLE
// ===================================================

var table db = table.new(
    position=position.top_right,
    columns=2,
    rows=11,
    bgcolor=color.new(#0d1117, 15),
    border_color=color.new(#30363d, 0),
    border_width=1,
    frame_color=color.new(#58a6ff, 50),
    frame_width=1
)

if show_dashboard and barstate.islast
    table.cell(db, 0, 0, "SMC V3.5.5 LEARNING ENGINE", text_color=#58a6ff, text_size=size.small, bgcolor=color.new(#161b22, 0), text_halign=text.align_center)
    table.cell(db, 1, 0, "STATISTICAL STATUS", text_color=#8b949e, text_size=size.small, bgcolor=color.new(#161b22, 0), text_halign=text.align_center)

    table.cell(db, 0, 1, "Active Confluence Pattern", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 1, current_pattern_id, text_color=#e3b341, text_size=size.tiny)

    table.cell(db, 0, 2, "Pattern Win Rate", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 2, str.tostring(active_pattern.win_rate, "#.#") + "% (" + str.tostring(active_pattern.wins) + "W / " + str.tostring(active_pattern.losses) + "L)", text_color=active_pattern.win_rate >= 60 ? #3fb950 : #f85149, text_size=size.tiny)

    table.cell(db, 0, 3, "Pattern Reliability Score", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 3, str.tostring(active_pattern.reliability_score) + "/100 (" + active_pattern.quality_status + ")", text_color=active_pattern.reliability_score >= min_reliability ? #3fb950 : #d29922, text_size=size.tiny)

    table.cell(db, 0, 4, "Consistency Score", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 4, str.tostring(active_pattern.consistency_score) + "/100", text_color=#58a6ff, text_size=size.tiny)

    table.cell(db, 0, 5, "Best Historical Pattern", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 5, export_BestPattern + " (" + str.tostring(export_BestPatternScore) + "/100)", text_color=#3fb950, text_size=size.tiny)

    table.cell(db, 0, 6, "Total Pattern Sample Size", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 6, str.tostring(active_pattern.occurrences) + " occurrences", text_color=#c9d1d9, text_size=size.tiny)

    table.cell(db, 0, 7, "Overall Learning Score", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 7, str.tostring(overall_learning_score) + "/100", text_color=#3fb950, text_size=size.tiny)

    table.cell(db, 0, 8, "Recorded Patterns in DB", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 8, str.tostring(array.size(db_patterns)) + " patterns", text_color=#58a6ff, text_size=size.tiny)

    table.cell(db, 0, 9, "ADX Trend Strength", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 9, str.tostring(math.round(adx_val, 1)), text_color=adx_val >= 25 ? #3fb950 : #8b949e, text_size=size.tiny)

    table.cell(db, 0, 10, "Current ATR (14)", text_color=#c9d1d9, text_size=size.tiny)
    table.cell(db, 1, 10, str.tostring(math.round(atr_val, 2)), text_color=#e3b341, text_size=size.tiny)

// ===================================================
// SECTION 9 — ALERTS
// ===================================================

alertcondition(active_pattern.reliability_score >= 85, title="High Reliability Pattern", message="🔥 SMC V3.5.5 HIGH RELIABILITY PATTERN DETECTED: {{ticker}} - Pattern: {{export_PatternID}}")
alertcondition(active_pattern.quality_status == "Improving", title="Pattern Reliability Improved", message="⚡ SMC V3.5.5 PATTERN RELIABILITY IMPROVED: {{ticker}}")

Overview

Smart Money Concepts V3.5.5 - Confluence Learning Engine maintains a statistical database of past setups, logs outcomes on bar close, and calculates dynamic win rates and reliability scores. The engine classifies patterns into quality states such as improving or stable. Active patterns receive labels on the price chart while a dashboard displays win rates, consistency scores, and best historical patterns. Settings control sample size, learning window, reliability thresholds, label visibility, and dashboard display. It draws on the price chart using moving averages, ADX, ATR, and volume filters to detect displacement moves.

Details

Published by

rehanqx on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Trend, Volatility & bands, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Minimum Sample Size for Patternint5min_sample_size
Historical Learning Window (bars)int200learning_window
Minimum Reliability Thresholdint70min_reliability
Show Active Pattern Labelsbooltrueshow_pattern_labels
Show Learning Intelligence Dashboardbooltrueshow_dashboard
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This technical indicator combines multiple popular analysis tools into a single price chart overlay to optimize chart space. It calculates and plots the complete Ichimoku Cloud, 50 and 200 Simple Moving Averages, and standard Bollinger Bands. Furthermore, it t

Indicator v5 TrendMoving averages Repaints
Updated 3 years ago · None stated GitHub repository of Ichimoku + MAs + Bollinger + Liquidity Zone
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

Bollinger Bands Force

by harryguiacorn
219 stars

This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i

Indicator v5 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Force

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers