OPEN-SOURCE SCRIPT
SmartFlow SMC

This indicator provides automated market structure analysis
based on Smart Money Concepts (SMC). It identifies structural
breaks, liquidity levels, and session timing using confirmed-
candle logic to eliminate repainting.
█ METHODOLOGY
Market Structure Detection (BoS / MSS)
The script uses pivot-based swing detection with a configurable
lookback period. Swing highs and lows are identified using
ta.pivothigh() and ta.pivotlow(), then tracked
to maintain structural history.
Break of Structure (BoS) is detected when a confirmed
candle's body (close[1]) exceeds the current swing target level
in the direction of the existing trend. This indicates trend
continuation.
Market Structure Shift (MSS) is detected when a confirmed
candle's body breaks the key pullback level against the existing
trend — the interim low in an uptrend or interim high in a
downtrend. This signals a potential trend reversal.
All detections use the previous closed bar [1], not the
current forming bar, ensuring signals do not repaint.
After a BoS is confirmed, the script tracks the highest high
(in uptrends) or lowest low (in downtrends) in real-time using
tracking variables. This compensates for the inherent delay in
pivot detection, so the BoS target level reflects actual price
extremes even before the next pivot formally confirms.
MSS Candidate Line
A dashed line drawn at the level where a trend reversal would
occur if broken. In an uptrend, this is the most recent pivot
low. In a downtrend, it is the most recent pivot high. This
provides advance visibility of where a structural shift would
trigger.
BoS Target Line
A dashed line showing the next level price needs to break for
trend continuation. Updates in real-time using both confirmed
pivots and tracked extremes.
█ LIQUIDITY DETECTION
Equal Highs / Equal Lows (EQH / EQL)
When two consecutive pivot highs (or lows) form within a
configurable tolerance percentage, they are marked as equal
levels. These represent clustered liquidity where stop orders
tend to accumulate — above for EQH (buy-side), below for EQL
(sell-side).
Buy Side / Sell Side Liquidity (BSL / SSL)
The most recent pivot high is marked as BSL, the most recent
pivot low as SSL. Only the latest level for each side is
displayed to maintain chart clarity.
Sweep Detection
A Sweep occurs when price wicks beyond a pivot level but the
candle body closes back inside. For a bullish sweep (SSL sweep),
the bar's low penetrates below the pivot low while both open and
close remain above it. This pattern indicates a liquidity grab
— price triggered stops below the level and reversed, suggesting
institutional accumulation. Bearish sweeps work inversely.
█ EMA 200
A 200-period Exponential Moving Average provides directional
bias context. The EMA line changes color based on whether
price is above (cyan, bullish bias) or below (red, bearish
bias). The info panel displays the EMA relationship as an
additional confluence filter.
When structure direction and EMA200 bias conflict (e.g.,
bullish structure but price below EMA200), the setup carries
lower confluence. When both align, the signal is stronger.
█ SESSION HIGHLIGHTING
Trading sessions are displayed as small colored squares at the
bottom of the chart:
Session times are adjustable and timezone-aware. This non-
intrusive display helps identify which session produced each
structural break.
█ INFO PANEL
A real-time table in the top-right corner displays:
█ WHAT MAKES THIS ORIGINAL
This indicator combines several concepts into a unified
structure-reading system:
1 — Hybrid pivot + tracking approach: After a pivot confirms,
the script continues tracking real-time highs/lows to compensate
for pivot detection delay. This is not standard in most SMC
indicators, which rely solely on pivot confirmation.
2 — Confirmed-candle logic throughout: All BoS, MSS, and Sweep
detections use close[1], ensuring zero repainting.
3 — MSS candidate + BoS target as live projection lines:
Rather than only marking historical events, the script projects
forward where the next structural break or reversal would occur.
4 — Sweep as a distinct event: Most SMC indicators treat sweeps
as part of BoS/CHoCH logic. This script separates sweep
detection (wick-based liquidity grab) from structural breaks
(body-based), allowing traders to distinguish between the two.
█ SETTINGS
Swing Lookback — Number of bars left and right to confirm
a pivot point. Lower values (3–4) detect more frequent swings.
Higher values (6–10) detect only major structure. Adjust based
on timeframe and instrument.
EQH/EQL Tolerance — Maximum percentage difference between
two pivot highs (or lows) for them to count as "equal."
Default: 0.05%.
Session Timezone — Adjusts session highlighting. Options:
Asia/Tokyo, Asia/Shanghai, UTC, America/New_York, Europe/London.
All visual elements (colors, visibility toggles) are individually
configurable in the settings panel.
█ USAGE NOTES
based on Smart Money Concepts (SMC). It identifies structural
breaks, liquidity levels, and session timing using confirmed-
candle logic to eliminate repainting.
█ METHODOLOGY
Market Structure Detection (BoS / MSS)
The script uses pivot-based swing detection with a configurable
lookback period. Swing highs and lows are identified using
ta.pivothigh() and ta.pivotlow(), then tracked
to maintain structural history.
Break of Structure (BoS) is detected when a confirmed
candle's body (close[1]) exceeds the current swing target level
in the direction of the existing trend. This indicates trend
continuation.
Market Structure Shift (MSS) is detected when a confirmed
candle's body breaks the key pullback level against the existing
trend — the interim low in an uptrend or interim high in a
downtrend. This signals a potential trend reversal.
All detections use the previous closed bar [1], not the
current forming bar, ensuring signals do not repaint.
After a BoS is confirmed, the script tracks the highest high
(in uptrends) or lowest low (in downtrends) in real-time using
tracking variables. This compensates for the inherent delay in
pivot detection, so the BoS target level reflects actual price
extremes even before the next pivot formally confirms.
MSS Candidate Line
A dashed line drawn at the level where a trend reversal would
occur if broken. In an uptrend, this is the most recent pivot
low. In a downtrend, it is the most recent pivot high. This
provides advance visibility of where a structural shift would
trigger.
BoS Target Line
A dashed line showing the next level price needs to break for
trend continuation. Updates in real-time using both confirmed
pivots and tracked extremes.
█ LIQUIDITY DETECTION
Equal Highs / Equal Lows (EQH / EQL)
When two consecutive pivot highs (or lows) form within a
configurable tolerance percentage, they are marked as equal
levels. These represent clustered liquidity where stop orders
tend to accumulate — above for EQH (buy-side), below for EQL
(sell-side).
Buy Side / Sell Side Liquidity (BSL / SSL)
The most recent pivot high is marked as BSL, the most recent
pivot low as SSL. Only the latest level for each side is
displayed to maintain chart clarity.
Sweep Detection
A Sweep occurs when price wicks beyond a pivot level but the
candle body closes back inside. For a bullish sweep (SSL sweep),
the bar's low penetrates below the pivot low while both open and
close remain above it. This pattern indicates a liquidity grab
— price triggered stops below the level and reversed, suggesting
institutional accumulation. Bearish sweeps work inversely.
█ EMA 200
A 200-period Exponential Moving Average provides directional
bias context. The EMA line changes color based on whether
price is above (cyan, bullish bias) or below (red, bearish
bias). The info panel displays the EMA relationship as an
additional confluence filter.
When structure direction and EMA200 bias conflict (e.g.,
bullish structure but price below EMA200), the setup carries
lower confluence. When both align, the signal is stronger.
█ SESSION HIGHLIGHTING
Trading sessions are displayed as small colored squares at the
bottom of the chart:
- Tokyo (09:00–15:00)
- London (16:00–21:00)
- New York (21:00–02:00)
Session times are adjustable and timezone-aware. This non-
intrusive display helps identify which session produced each
structural break.
█ INFO PANEL
A real-time table in the top-right corner displays:
- Bias (Long/Short based on structure direction)
- EMA200 position (Above/Below)
- Current active session
- Structure direction (Bullish/Bearish)
- Swing Lookback value in use
█ WHAT MAKES THIS ORIGINAL
This indicator combines several concepts into a unified
structure-reading system:
1 — Hybrid pivot + tracking approach: After a pivot confirms,
the script continues tracking real-time highs/lows to compensate
for pivot detection delay. This is not standard in most SMC
indicators, which rely solely on pivot confirmation.
2 — Confirmed-candle logic throughout: All BoS, MSS, and Sweep
detections use close[1], ensuring zero repainting.
3 — MSS candidate + BoS target as live projection lines:
Rather than only marking historical events, the script projects
forward where the next structural break or reversal would occur.
4 — Sweep as a distinct event: Most SMC indicators treat sweeps
as part of BoS/CHoCH logic. This script separates sweep
detection (wick-based liquidity grab) from structural breaks
(body-based), allowing traders to distinguish between the two.
█ SETTINGS
Swing Lookback — Number of bars left and right to confirm
a pivot point. Lower values (3–4) detect more frequent swings.
Higher values (6–10) detect only major structure. Adjust based
on timeframe and instrument.
EQH/EQL Tolerance — Maximum percentage difference between
two pivot highs (or lows) for them to count as "equal."
Default: 0.05%.
Session Timezone — Adjusts session highlighting. Options:
Asia/Tokyo, Asia/Shanghai, UTC, America/New_York, Europe/London.
All visual elements (colors, visibility toggles) are individually
configurable in the settings panel.
█ USAGE NOTES
- Works on any instrument (Forex, Commodities, Crypto, Indices)
- Works on any timeframe — adjust Swing Lookback accordingly
- BoS and MSS labels appear one bar after the signal bar
- Designed as an overlay indicator — apply directly to chart
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
SmartFlow Pro — SMC detection (OB/BOB, FVG/iFVG, OTE, Confluence, Alerts) +
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
SmartFlow Pro — SMC detection (OB/BOB, FVG/iFVG, OTE, Confluence, Alerts) +
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
Position Sizer Pro — (partial TP, trailing SL, risk mgmt).
→ whop.com/smartflow-indicators/smartflow-pro/
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.