QML FTB with Quality Score [Malibu]QML FTB with Quality Score
Overview
QML FTB with Quality Score is an open-source market structure indicator designed to detect Quasimodo (QML) reversal formations and highlight potential First Touch Back (FTB) reaction levels after a confirmed break of structure.
The script is built to be selective rather than frequent. Instead of displaying every possible QML pattern, it filters structure through multiple confluence factors and ranks each setup with a normalized Quality Score. The goal is to help traders focus on cleaner and more meaningful reaction zones rather than treating all reversal structures as equal.
What this indicator does
This indicator scans price action for bullish and bearish Quasimodo formations, confirms the related market structure break, and projects the corresponding left-shoulder area as a potential reaction level.
In practical terms, it is a structure-based reversal and reaction-zone tool that can assist with:
- market structure shifts
- support and resistance transitions
- break-of-structure confirmation
- liquidity-driven reversal analysis
- filtered first-touch retest opportunities
Why this indicator can be useful
Raw QML detection can become noisy because many structures may appear valid at first glance, but not all of them carry the same quality. This script attempts to solve that problem by combining pattern detection with context-based filtering.
Instead of only drawing a shape, it asks additional questions:
- Was the structure break strong enough?
- Is momentum aligned?
- Is there RSI divergence?
- Is there Fair Value Gap confluence?
- Was liquidity swept before the reversal?
- Is the level still fresh and untouched?
That layered process is what makes the script more selective and more practical for traders who prefer structured filtering over raw pattern frequency.
How it works
The script uses a ZigZag-style swing engine to track meaningful highs and lows in price structure. Based on those swings, it evaluates whether the sequence forms a valid Quasimodo transition.
Bullish structure:
- price forms a lower low
- price then breaks the prior key high
- the previous shoulder area becomes the projected bullish QML / FTB level
Bearish structure:
- price forms a higher high
- price then breaks the prior key low
- the previous shoulder area becomes the projected bearish QML / FTB level
Once the structure is identified, the setup can be refined through optional confluence filters. The script then calculates a Quality Score and prints the confirmed level only after bar close.
Filtering logic
1) Body Break Filter
This filter requires the break of structure to happen with candle body confirmation rather than wick-only penetration. Its purpose is to reduce weak or cosmetic breaks and focus on clearer structural shifts.
2) Momentum Filter (EMA)
This filter checks whether the setup is aligned with the broader directional bias using an EMA-based trend condition. Bullish setups are generally stronger when price is positioned in bullish momentum context, while bearish setups are generally stronger when price is positioned in bearish momentum context.
3) RSI Divergence Filter
This filter looks for momentum exhaustion. For bullish setups, it checks whether price pushes lower while RSI fails to confirm that weakness. For bearish setups, it checks the opposite. This is the strictest filter and is meant to isolate higher-selectivity reversal conditions.
4) FVG Confluence
This filter checks whether the projected QML level aligns with a Fair Value Gap area. The aim is to add imbalance context and identify zones where inefficient price delivery may support a reaction.
5) Liquidity Sweep Filter
This filter checks whether the head of the QML structure swept prior liquidity before the reversal. It is meant to capture structural traps and stop-hunt style behavior before a turn.
6) Freshness (FTB) Filter
This filter removes levels that have already been touched or used. Its goal is to keep the focus on first-touch reaction opportunities rather than repeatedly tested zones.
Quality Score logic
The script ranks each setup using a normalized Quality Score.
Current score components:
- RSI Divergence: +30
- FVG Confluence: +25
- Liquidity Sweep: +25
- EMA Momentum Alignment: +20
The total score is normalized according to the filters that are currently active, then displayed as a percentage. This allows the indicator to remain usable even when traders prefer a lighter or stricter filter stack.
What it plots on the chart
The indicator can display:
- a thick horizontal QML entry level
- optional dashed ZigZag structure lines
- bullish and bearish QML labels
- a Quality Score percentage
- an additional symbol when RSI divergence is present
The visual design is intentionally simple so the underlying structure remains readable on chart.
Inputs
ZigZag Sensitivity (default: 13)
Controls how sensitive the swing detection is.
- Lower values produce more swing points and more signals, but also more noise.
- Higher values reduce signal frequency and generally improve selectivity, but can introduce more lag.
Body Break Filter (default: true)
Requires structure breaks to happen with body confirmation.
- Usually lowers signal count
- Usually improves reliability
- Best kept enabled in noisier conditions
Momentum Filter / EMA Filter (default: true)
Restricts setups to those aligned with EMA direction.
- Reduces counter-trend signals
- Makes the script more selective
- Generally improves quality in directional markets
EMA Period (default: 50)
Defines the trend filter length.
- Lower values make the filter more responsive
- Higher values make it smoother and slower
RSI Divergence Filter (default: false)
Allows only setups that also show RSI divergence.
- This is the strictest filter
- Strongly reduces signal frequency
- Best used when only higher-selectivity reversal setups are desired
FVG Confluence (default: true)
Requires the level to align with Fair Value Gap context.
- Filters out some otherwise valid patterns
- Can improve contextual quality in imbalanced markets
Liquidity Sweep Filter (default: true)
Requires evidence of liquidity interaction at the head of the structure.
- Helps isolate trap-like reversal conditions
- Adds selectivity around structural extremes
Freshness (FTB) Filter (default: true)
Rejects previously tested levels.
- Keeps the focus on first-touch setups
- Useful for traders who prefer untouched zones
Line Length (bars) (default: 25)
Controls how far the projected QML level is extended to the right.
- This is a visual setting
- It does not change the signal logic
Which settings matter most
The three most important inputs are:
- ZigZag Sensitivity
- Body Break Filter
- Freshness (FTB) Filter
These settings have the biggest impact on how noisy, selective, and practical the final output becomes.
Suggested usage styles
Balanced / default use
For most users, the default settings are the best place to start. They are designed to provide a practical balance between signal frequency and selectivity.
More aggressive use
For traders who want more setups:
- reduce ZigZag Sensitivity toward 8–10
- consider disabling EMA Filter
- consider disabling FVG Confluence
This can increase opportunity count, but it also increases noise and false positives.
More conservative use
For traders who want fewer but stronger setups:
- keep Body Break Filter enabled
- keep Freshness Filter enabled
- enable RSI Divergence Filter
- focus more on higher-score setups, especially 80%+
This creates a much stricter selection process.
Timeframe behavior
This indicator is generally better suited to M15, H1, H4, and Daily charts.
Suggested sensitivity behavior:
- M15 to H1: 13 to 21 is usually more stable
- H4 to Daily: 8 to 13 is often more responsive without becoming overly delayed
Timeframe notes:
- On M1 and M5, low sensitivity settings can produce excessive noise and weak structure breaks.
- In lower timeframes, Body Break confirmation becomes much more important.
- On higher timeframes, very high sensitivity values can reduce opportunities too much and may introduce unnecessary delay.
Market conditions
The script tends to behave more cleanly in liquid markets where structure is clearer, such as:
- crypto majors
- forex majors
- index products
- other actively traded instruments
In very thin or highly irregular markets, the structural quality of setups may degrade.
Why this indicator may be preferred over simpler alternatives
This script is not intended to be just a basic ZigZag visualizer or a simple Quasimodo marker.
Its main differentiator is the way it combines multiple layers of structure validation into one ranked workflow:
- structure recognition
- body-based break confirmation
- momentum alignment
- divergence context
- FVG context
- liquidity sweep context
- freshness filtering
- normalized quality scoring
Instead of showing every possible shape, it tries to separate weaker structural patterns from more meaningful ones.
What makes this script different
The individual concepts used here are known market-structure concepts, but the practical value of the script comes from how they are combined.
Its distinguishing contribution is the orchestration layer:
- the Quality Score model
- the multi-filter ranking process
- the first-touch freshness workflow
- the compact integration of structure, momentum, liquidity, and imbalance into one decision-support tool
In other words, the script is built on generic market-structure concepts, but its filtering and ranking workflow is specific to this implementation.
How to use it in practice
A common workflow is:
- wait for a level to be confirmed
- monitor the first return into that level
- use the score and filter context to judge whether the setup deserves attention
- avoid treating every printed level as a guaranteed reversal
Many users will find it most useful as a structured decision-support tool rather than as a standalone entry engine.
Technical behavior
- Signals are confirmed on bar close.
- Confirmed levels remain fixed after printing.
- The script does not rely on request.security() in the described signal logic.
- No lookahead-based behavior is used in the signal confirmation process.
- The latest developing pivot may evolve while structure is still forming, but confirmed outputs are only printed after confirmation.
Alerts
The script includes on-close alerts when a new bullish or bearish QML level is confirmed.
Alert messages can include contextual details such as:
- direction
- Quality Score
- divergence state
Limitations
This script is a technical analysis tool, not a prediction engine.
Please keep in mind:
- sideways conditions can generate weaker structural setups
- very low timeframes can create more noise and false breaks
- news-driven volatility can invalidate technical levels quickly
- very low ZigZag Sensitivity settings can make ordinary pullbacks look more important than they really are
- no indicator can guarantee that price will react from every marked level
For that reason, the script is best used as a structured analysis tool rather than as a certainty model. Indikator

Quasimodo (QML) Pattern [UAlgo]Quasimodo (QML) Pattern is a market structure pattern detector that identifies Quasimodo formations using confirmed swing pivots and then visualizes the full structure directly on the chart. The Quasimodo concept is often described as a stop run and reversal model where price first violates a prior swing point, then breaks structure in the opposite direction. This script formalizes that idea into a strict pivot sequence and draws the key structural components so the pattern can be reviewed consistently.
The indicator maintains a rolling history of pivot highs and pivot lows, then checks the most recent four pivots for a valid Quasimodo sequence. When a bullish or bearish QML is confirmed, the script draws a connected structure, highlights the pattern area with a fill, plots a Market Structure Break reference line, and marks a QML zone derived from the left shoulder and the head. The most recent pattern zone is extended forward to keep it visible for potential retests.
This tool is intended to support structured analysis of reversal setups, with visual anchors that make it easy to locate left shoulder, reaction, head, and MSB points without manual drawing.
🔹 Features
1) Pivot Based Swing Engine
The script uses pivot highs and pivot lows to define swings. Left Bars and Right Bars control how many bars are required to confirm each pivot. This creates stable swing points and reduces noise compared to raw candle comparisons.
Confirmed pivots are stored as PivotPoint objects with price, bar index, and direction (high or low). The pivot history is capped to keep memory efficient while retaining enough context for detection.
2) Strict Four Pivot Pattern Validation
Detection uses the most recent four pivots, enforcing an alternating sequence so the structure follows a zig zag pattern. Only sequences that alternate high and low consistently are eligible for classification.
This avoids false detections where multiple highs or multiple lows occur in a row.
3) Bullish QML Detection Logic
The bullish model requires:
Left shoulder is a low
Reaction is a high
Head is a lower low than the left shoulder
MSB is a higher high than the reaction
This represents a liquidity grab below the prior swing low followed by a break above the reaction high, which is treated as the structure break confirmation.
4) Bearish QML Detection Logic
The bearish model requires:
Left shoulder is a high
Reaction is a low
Head is a higher high than the left shoulder
MSB is a lower low than the reaction
This represents a liquidity grab above the prior swing high followed by a break below the reaction low.
5) Full Pattern Visualization with Structural Labels
When a pattern is detected, the script draws:
Three visible connector lines linking left shoulder to reaction, reaction to head, and head to MSB
A filled highlight over the core structure area to emphasize the liquidity grab geometry
Point labels at left shoulder, head, and MSB for quick reading
A descriptive pattern label showing Bullish QML or Bearish QML
Visual styling, colors, and label sizing are user configurable.
6) MSB Break Reference Line
A dotted horizontal line is drawn from the reaction point to the MSB point at the reaction price level. This acts as a clear market structure break reference and helps validate that the break level was actually exceeded in the required direction.
7) QML Zone Projection
The script draws a QML zone box that spans the price range between the left shoulder and the head. This zone is extended forward in time so it remains visible for potential retests and reactions.
8) Efficient Execution and Update Behavior
Pattern checks run only when a new pivot is confirmed, reducing repeated evaluation. The script also extends the most recent QML zone and repositions the main label forward for better ongoing visibility.
🔹 Calculations
1) Pivot Detection
Pivot highs and pivot lows are confirmed using Left Bars and Right Bars:
float ph = ta.pivothigh(leftLen, rightLen)
float pl = ta.pivotlow(leftLen, rightLen)
When a pivot is confirmed, the bar index is aligned to the pivot location using the rightLen offset:
if not na(ph)
pivotArray.pushPivot(ph, bar_index , true)
if not na(pl)
pivotArray.pushPivot(pl, bar_index , false)
Each pivot is stored as:
price
index
isHigh flag
2) Alternating Sequence Requirement
The script evaluates the last four pivots p0 through p3 and requires strict alternation:
bool correctSequence =
(p0.isHigh != p1.isHigh) and (p1.isHigh != p2.isHigh) and (p2.isHigh != p3.isHigh)
This ensures the sequence forms a valid zig zag structure.
3) Bullish Quasimodo Conditions
Bullish QML is evaluated when p0 is a low:
if not p0.isHigh
if p2.price < p0.price and p3.price > p1.price
Quasimodo qml = Quasimodo.new(p0, p1, p2, p3, true)
Interpretation:
Head is a lower low relative to the left shoulder
MSB is a higher high relative to the reaction
This produces a sweep and reversal structure with confirmation
4) Bearish Quasimodo Conditions
Bearish QML is evaluated when p0 is a high:
if p0.isHigh
if p2.price > p0.price and p3.price < p1.price
Quasimodo qml = Quasimodo.new(p0, p1, p2, p3, false)
Interpretation:
Head is a higher high relative to the left shoulder
MSB is a lower low relative to the reaction
5) Pattern Drawing Components
When a pattern is confirmed, the script draws connecting lines:
line.new(LS.index, LS.price, R.index, R.price)
line.new(R.index, R.price, H.index, H.price)
line.new(H.index, H.price, MSB.index, MSB.price)
It also draws a horizontal MSB reference at the reaction price:
line.new(reaction.index, reaction.price, msb.index, msb.price, style=line.style_dotted)
A QML zone box is created using left shoulder and head prices and extended forward:
qml.qmlZone := box.new(LS.index, LS.price, bar_index + 10, H.price, bgcolor=color.new(col, 85))
On each bar, the most recent zone is extended further to remain visible:
box.set_right(lastQml.qmlZone, bar_index + 5)
label.set_x(lastQml.lbl, bar_index + 5)
6) Pivot History Management
To keep execution efficient, the pivot array is capped:
if pivots.size() > 50
pivots.shift()
Pattern checking is triggered only when a new pivot is found, which reduces redundant processing on bars where no structural update occurred. Indikator

Quasimodo (QML) Pattern [Kodexius]Quasimodo (QML) Pattern is a market structure indicator that automatically detects Bullish and Bearish Quasimodo formations using confirmed swing pivots, then visualizes the full structure directly on the chart. The script focuses on the classic liquidity-grab narrative of the QML: a sweep beyond a prior swing (the Head) followed by a decisive market structure break (MSB), leaving behind a clearly defined reaction zone between the Left Shoulder and the Head.
Detection is built on pivot highs and lows, so patterns are evaluated only after swing points are validated. Once a valid 4 pivot sequence is identified, the indicator draws the pattern legs, highlights the internal triangle area to emphasize the grab, marks the MSB leg, and projects a QML zone that can be used as a potential area of interest for retests.
This tool is designed for traders who work with structure, liquidity concepts, and reversal/continuation triggers, and who want a clean, repeatable QML visualization without manually marking swings.
🔹 Features
🔸 Confirmed Pivot Based Structure Mapping
The script uses classic built-in pivot logic to detect swing highs and swing lows.
🔸 Automatic Bullish and Bearish QML Detection
The indicator evaluates the most recent 4 pivots and checks for a valid alternating sequence (High-Low-High-Low or Low-High-Low-High). When the sequence matches QML requirements, the script classifies the setup as bullish or bearish:
Bullish logic (structure reversal up):
- Left Shoulder is a pivot Low
- Head is a lower Low than the Left Shoulder (liquidity sweep)
- MSB pivot exceeds the Reaction pivot
Bearish logic (structure reversal down):
- Left Shoulder is a pivot High
- Head is a higher High than the Left Shoulder (liquidity sweep)
- MSB pivot breaks below the Reaction pivot
🔸 Full Pattern Visualization (Legs + Highlighted Core)
When a pattern triggers, the script draws:
Three main legs: Left Shoulder to Reaction, Reaction to Head, Head to MSB
A shaded triangular highlight over the internal structure to make the liquidity-grab shape easy to spot at a glance
🔸 QML Zone Projection
A QML Zone box is drawn using the price range defined between the Left Shoulder and the Head, then extended to the right to remain visible as price develops. This zone is intended to act as a practical reference area for potential retests and reaction planning after MSB confirmation.
🔸 MSB Emphasis
A dotted MSB line is drawn between the Reaction point and the MSB point to visually emphasize the confirmation leg that completes the pattern logic.
🔸 Clean Point Tagging and Directional Labeling
Key points are labeled directly on the chart:
- “LS” at the Left Shoulder
- “Head” at the sweep pivot
- “MSB” at the break pivot
A directional label (“Bullish QML” or “Bearish QML”) is also printed to quickly identify the detected bias.
🔸 Configurable Visual Style
All main visual components are user configurable:
- Bullish and bearish colors
- Line width
- Label size
🔸 Efficient Update Logic
Pattern checks are only performed when a new pivot is confirmed, avoiding unnecessary repeated calculations on every bar. The most recent pattern’s projected elements (zone and label positioning) are updated as new bars print to keep the latest setup readable.
🔹 Calculations
This section summarizes the core logic used for detection and plotting.
1. Pivot Detection (Swing Highs and Lows)
The script relies on confirmed pivots using the user inputs:
Left Bars: how many bars must exist to the left of the pivot
Right Bars: how many bars must exist to the right to confirm it
float ph = ta.pivothigh(leftLen, rightLen)
float pl = ta.pivotlow(leftLen, rightLen)
When a pivot is confirmed, its true bar index is the pivot bar, not the current bar, so the script stores:
bar_index
2. Pivot Storage and History Window
Each pivot is stored as a structured object containing:
- price
- index
- isHigh (true for pivot high, false for pivot low)
A rolling history is maintained (up to 50 pivots) to keep processing stable and memory usage controlled.
3. Sequence Validation (Alternation Check)
The pattern evaluation always uses the latest 4 pivots:
p0: Left Shoulder candidate
p1: Reaction candidate
p2: Head candidate
p3: MSB candidate
Before checking bullish/bearish rules, the script enforces alternating pivot types:
bool correctSequence =
(p0.isHigh != p1.isHigh) and
(p1.isHigh != p2.isHigh) and
(p2.isHigh != p3.isHigh)
This prevents invalid structures like consecutive highs or consecutive lows from being interpreted as QML.
4. Bullish QML Conditions
A bullish QML is evaluated when the Left Shoulder is a Low:
Head must be lower than Left Shoulder (sweep)
MSB must be higher than Reaction (break)
if not p0.isHigh
if p2.price < p0.price and p3.price > p1.price
// Bullish QML confirmed
Interpretation:
p2 < p0 represents the liquidity grab below the prior swing low
p3 > p1 represents the market structure break above the reaction high
5. Bearish QML Conditions
A bearish QML is evaluated when the Left Shoulder is a High:
Head must be higher than Left Shoulder (sweep)
MSB must be lower than Reaction (break)
if p0.isHigh
if p2.price > p0.price and p3.price < p1.price
// Bearish QML confirmed
Interpretation:
p2 > p0 represents the liquidity grab above the prior swing high
p3 < p1 represents the market structure break below the reaction low
6. Drawing Logic (Structure, Highlight, Zone, Labels)
When confirmed, the script draws:
Three connecting legs (LS to Reaction, Reaction to Head, Head to MSB)
A shaded triangle using a transparent “ghost” line to enable filling
A dotted MSB emphasis line between Reaction and MSB
A QML Zone box spanning the LS to Head price range and projecting to the right
Point labels: LS, Head, MSB
A direction label: “Bullish QML” or “Bearish QML”
7. Latest Pattern Extension
To keep the newest setup readable, the script updates the most recently detected pattern by extending its projected elements as new bars print:
QML zone right edge is pushed forward
The main label x position is pushed forward
This keeps the last identified QML zone visible as price evolves, without having to redraw historical patterns on every bar. Indikator

QM Signal [TradingFinder] Quasimodo Pattern - Head and Shoulders🔵 Introduction
One of the patterns in "RTM" is the "QM" pattern, also known as "Quasimodo". Its name is derived from the appearance of "Hunchback of Notre-Dame" from Victor Hugo's novel. It is a type of "Head and Shoulders" pattern.
🔵 Formation Method
🟣 Upward Trend
In an upward trend, the left shoulder is formed, and the price creates a new peak higher than the left shoulder peak . After a decline, it manages to break the previous low and move upward again. We expect the price to return approximately between and to form the "QM" pattern.
🟣 Downward Trend
In a downward trend, with a price decline, a new valley is created, forming the left shoulder, and the price forms a new valley lower than the left shoulder valley . After a price increase, it manages to break the previous high and move downward again. We expect the price to return approximately between and to form the "Quasimodo" pattern.
Note: The "QM" pattern is a specific type of head and shoulders pattern in which in the first move, the previous support is broken and it's the best condition for price reversal.
🔵 Entry Conditions for "Buy" and "Sell"
🟢 Buy
Buy Position : When a complete "QM" pattern is formed in a downtrend; we expect the price to reach the left shoulder area (with confirmation) during the retracement to enter the "BUY" position.
Profit Target in Buy Scenario : Expecting a move to the peak that broke it and the highest point in the current "Swing".
Stop Loss : Below the "Head," which is the lowest point.
🔴 Sell
Sell Position : When a "QM" pattern is formed in an uptrend, we look for entry into the "Sell" position as the price retraces to the left shoulder area.
Profit Target in Sell Scenario : Expecting a move to the price floor that has been broken and the entire "Swing" or .
Take Profit : Above the highest point or above the area will be the "SL" region.
Note : Certainly, no method alone guarantees trading capability and requires different confirmations. This indicator only detects the "QM" pattern, and the rest of the analysis will be the responsibility of the user.
Note : These profit and loss limits are based on market movements and will be provided as approximate and supportive.
Indikator

Indikator
