Mis à jour

Smart Money Concept ML [PickMyTrade]

10 766
Price breaks a swing level. Do you take the break, or wait for a retest?
Smart Money Concept ML brings that question onto the chart: structure and liquidity mapped together, a retest estimate recorded at each swing break, and a running check of how those estimates compare with what actually happened.

snapshot
――――――――――――――――――――――――――――――――――――――

🔷 WHAT IT MEASURES

🔸 Break of Structure (BOS) in the established direction and Change of Character (CHoCH) against it, using confirmed swing points
🔸 Order blocks, optional fair value gaps, equal highs and lows, and the protected and opposing extremes of the current range
🔸 Order blocks, optional fair value gaps, equal highs and lows, and the protected and opposing extremes of the current range. Optional internal structure shows shorter swings; premium/discount shading shows the two halves of the dealing range
🔸 Retest odds — the estimated chance of price touching the broken swing level within the selected number of bars. A touch counts as a retest; it does not require a bounce or a successful trade
🔸 Liquidity odds — the estimated chance of the nearest untaken pool above price being traded through before the nearest pool below, and vice versa
――――――――――――――――――――――――――――――――――――――

🔷 THE LEARNING ENGINE

🔸 Retest estimates begin with a random-walk calculation using distance from the broken level, recent price-change volatility, and the retest window. The mathematical basis is the reflection principle
🔸 Liquidity estimates begin with the standard gambler’s-ruin first-touch calculation: where price sits between two boundaries
🔸 Bayesian logistic calibration adjusts these starting estimates as outcomes resolve on the chart. Retest calibration learns an intercept and slope; liquidity calibration learns a slope while preserving complementary upper and lower odds
🔸 This calibration is the learned component behind “ML.” Structure detection, zones, and signal rules are explicitly defined in the code
🔸 Each calibration fit uses its latest 500 resolved observations at most, with a prior that pulls it toward the starting formula when evidence is limited. The table reads LEARNING until 30 break observations have been scored as retested or not retested; fitting already takes place during that period. Displayed scoring totals can exceed 500
🔸 Each recorded estimate is scored before its own outcome is used to update the model
🔸 A retest observation resolves on its first later touch or when its window expires. Liquidity calibration samples qualifying setups at swing breaks; setups that cross both pools on one bar or remain unresolved after 1,000 bars are excluded
――――――――――――――――――――――――――――――――――――――

🔷 CHECKING THE EVIDENCE

🔸 Calibration compares the average recorded estimate with the observed event rate and shows the sample count. Tooltips add probability-error comparisons against the unadjusted formula and the chart’s running base rate
🔸 The Edge Test compares three groups: BOS versus CHoCH, breaks with versus without a fair value gap in the leg, and breaks preceded versus not preceded by a liquidity sweep
🔸 Follow-through means a close one risk unit beyond the break close before a close through the protected swing. Unresolved observations expire after 150 bars and are excluded
🔸 A two-proportion test, adjusted for the three comparisons, checks whether an observed difference exceeds its statistical threshold. This describes the loaded sample; it does not establish a lasting trading advantage
――――――――――――――――――――――――――――――――――――――

🔷 SIGNALS AND DISPLAY

🔸 Break Close records a hypothetical entry on a qualifying confirmed swing break. Level Retest waits within the selected window for a later bar to touch the level and close back beyond it in the break direction; a close through the protected swing cancels the setup. Adaptive waits only when the retest estimate meets its threshold
🔸 Stops sit beyond the protected swing, with an ATR buffer. Two targets are expressed as multiples of initial risk, with an optional move of the stop to entry after TP1
🔸 One signal is tracked at a time. Same-direction signals are skipped; an opposing signal closes the existing position at the bar’s close
🔸 The hypothetical Record scores half the position at TP1 and the remainder at TP2 or another exit. If TP1 is never reached, the full position is scored at the exit. It reports average R, adds an approximate 95% interval from 10 closed signals, and labels fewer than 30 as too few to judge
🔸 Blue marks bullish structure and orange marks bearish structure. Display toggles control the zones and labels; Zen Mode hides labels and the table
🔸 Alerts cover structure breaks, liquidity sweeps, and signal events. Select “Any alert() function call” for the combined entry and exit stream, available as Text or JSON
🔸 Eight separate alert conditions cover BUY, SELL, signal closure, bullish and bearish CHoCH, bullish and bearish BOS, and liquidity sweeps. The combined Text/JSON signal stream is described below
――――――――――――――――――――――――――――――――――――――

🔷 ALERTS AND AUTOMATION

🔸 Supports webhook-based automation through TradingView alerts and an external receiver configured for this script’s message format. The indicator generates signals; the receiving service handles order execution
🔸 Choose Text for readable notifications or JSON for structured integration. JSON includes source, event, action, position, side, symbol, timeframe, price, entry, sl, tp1, and tp2
🔸 Signal events include entry, TP1, TP2, stop loss, stop at entry, timeout, and reversal. The action field identifies buy, sell, partial_close, or close. The side field describes the original position direction, including on exits; receivers should use action and position to interpret an exit
🔸 After selecting the symbol, timeframe, and script inputs, set Alert Message Format to JSON and create an alert using “Any alert() function call.” Add your receiver’s webhook URL in the alert settings. TradingView requires two-factor authentication for webhooks
🔸 Messages are emitted on confirmed bar closes. A reported stop or target price is the script’s reference price for the event, not confirmation of an external fill. On a reversal, the close message is sent before the new entry message
🔸 The payload does not include order quantity, account credentials, or a unique event ID. Position sizing, symbol mapping, duplicate handling, and execution rules must be configured in the receiver. Compatibility with a particular execution platform depends on its required payload
🔸 A TP2 event can occur without a separate TP1 message. If multiple exit events occur on one bar, only the final assigned exit message is sent. The receiver must account for this when managing partial exits; the chart’s hypothetical 50% allocation is not an order-size instruction in the payload
🔸 Recreate the alert after changing script code, inputs, symbol, or timeframe: an existing TradingView alert runs its saved configuration. Hiding Buy/Sell signals changes their display; it does not disable the underlying alert logic
――――――――――――――――――――――――――――――――――――――

🔷 INPUTS

Swing Length / Internal Length — bars on each side needed to confirm a pivot. Defaults 10 / 3.
Order Blocks — number retained per side. Default 2.
Fair Value Gap Minimum / Equal-Level Tolerance — defaults 0.30 / 0.15 ATR.
Retest Window — time allowed for a return to the broken level. Default 20 bars.
Entry — Break Close, Level Retest, or Adaptive. Default Break Close.
Adaptive Threshold — estimate required to wait for a retest in Adaptive mode. Default 80%.
Breaks That Signal — CHoCH, BOS, or both. Default both.
Stop Buffer / Maximum Risk — defaults 0.20 / 6.0 ATR; wider setups are skipped.
TP1 / TP2 — defaults 1R / 2R. Stop to entry after TP1 is enabled by default.
Trade Timeout — default 150 bars.
Alert Message Format — Text or JSON. Default Text.
――――――――――――――――――――――――――――――――――――――

🔷 REQUIREMENTS AND LIMITATIONS

🔸 Use standard price bars. Synthetic chart prices can distort the measurements and hypothetical fills
🔸 Pivots become available only after their right-side confirmation bars close. A swing marker identifies an earlier bar; it was not available on that bar
🔸 Breaks, signals, and recorded estimates are committed at bar close. Live liquidity odds and the premium/discount reading can change during the current bar
🔸 Learning starts from the loaded history. Loading a different stretch of data can change calibration, historical estimates, diagnostics, and Adaptive signals
🔸 Random-walk assumptions simplify market behavior. Overlapping observations can also make statistical intervals appear more precise than the evidence warrants
🔸 Retest and liquidity percentages describe specific touch events, not win rates. The signal record is hypothetical, excludes commission and slippage, and is not a Strategy Tester backtest
🔸 When a later bar touches both a stop and a target, the record gives the stop priority. Chart bars cannot reveal every intrabar price sequence
――――――――――――――――――――――――――――――――――――――
Built in Pine Script v6. Open source — Mozilla Public License 2.0.
Notes de version
Smart Money Concept ML — v2: Historical structure

This update makes earlier market structure easier to read. The previous display kept six swing breaks and twenty internal breaks, so much of the structure disappeared when reviewing an older period. Historical mode now rebuilds confirmed events inside the visible chart window when you scroll or zoom.

🔷 Historical structure
🔸 Swing BOS and CHoCH use solid lines. Internal structure is enabled by default and uses dashed lines with smaller i-BOS and i-CHoCH labels. BOS identifies a break in the tracked direction; CHoCH identifies a break against it. The first break before a direction is established is classified as BOS.
🔸 The default limits are 120 swing breaks, 160 internal breaks and 40 EQH/EQL pairs per visible window. The respective maximums are 180, 180 and 60. At a limit, older drawings in that window are omitted; zoom into the earlier period to rebuild them. Coverage depends on the history TradingView has loaded.
🔸 Historical EQH/EQL links join two confirmed internal pivots within the ATR tolerance. They stop at the second pivot and remain after a sweep. They show a historical formation, not a claim that its liquidity is still resting.
🔸 Optional HH/HL/LH/LL labels retain up to 40 confirmed swing points. Recent mode keeps the original short-history presentation and active equal-high/low pools.

🔷 Reading the chart
🔸 Blue means bullish structure; orange means bearish structure. EQH uses orange and EQL blue. Solid = swing structure, dashed = internal structure, dotted = historical equal-high/low pair.
🔸 Past entry signals now show only their blue/orange arrows, without BUY/SELL text. The current active trade keeps its right-edge entry-price label.
🔸 Swing label size and placement are configurable. Choose Middle of level or Break bar. Retest percentages can be shown beside the latest break; historical labels remain short, with details in hover tooltips.
🔸 The optional Publication heading and key adds the chart heading and legend. The full info table remains available separately. These display controls do not change the signal or learning rules.

🔷 How to use v2
1. Open a standard candlestick chart and keep Structure View set to Historical.
2. Keep Show Internal Structure enabled for the minor structure, or disable it for a simpler swing-only map.
3. Scroll to the period you want to examine and allow the drawings to recalculate. Zoom in if labels overlap. The info table reports displayed history counts and limits.
4. Enable Show Swing Labels for HH/HL/LH/LL. Order blocks, fair value gaps, liquidity odds, signals and the info table have separate controls.
5. Hover a structure label for its price and confirmation time, shown in the exchange timezone. Break bar placement anchors the text at that confirming bar.

🔷 Code review and clarifications
The EQ-pair check now rejects pairs whose intervening span exceeds its 300-bar scan. The previous capped scan could overlook a violation in an unchecked earlier part of a widely separated pair. This correction can change affected liquidity pools, their outcomes and related estimates.

The learning description has also been corrected: calibration starts with the first resolved sample, with a strong prior toward the random-walk formula. LEARNING means fewer than 30 resolved samples; it does not mean calibration is disabled. Retest estimates use an intercept and slope fitted to earlier resolved outcomes. Liquidity calibration fixes the intercept at zero and fits the slope. No new ML model or predictive-performance claim is introduced in v2.

🔷 Timing and limitations
Pivots need the selected Swing Length or Internal Length of right-hand bars to confirm. Their historical locations are marked only after that delay. A structure break requires a confirmed close through a standing pivot level. A label centred on an earlier level is not an earlier signal.

Panning selects drawings; it does not rewind the model. The dashboard, active zones, current trade levels and live liquidity estimates still describe the latest loaded bar. Retest outcomes in tooltips are later observations. Use Bar Replay for an earlier as-of state.

Loading different history can change calibration, counts and estimates; Adaptive entry can also change because it uses those estimates. The record remains hypothetical, without commission or slippage, and is not a broker execution report. TP1 is scored at its target even on gaps; stop and TP2 exits use the opening price when it gaps beyond the applicable level. Same-bar stop/target conflicts are scored stop-first, and a stop moved to entry after TP1 applies from the next bar. These are OHLC simulation conventions, not intrabar execution evidence.

The eight existing alertconditions and the Text/JSON alert interface remain available. Create alerts from the updated script if you want them to use v2; existing TradingView alerts retain their saved script/settings snapshot. No broker integration is demonstrated by this update.

This is an update to this author's existing implementation. It expands historical display and adds the bounded EQ-pair correction; it does not introduce another author's SMC source code. Historical observations and calibrated estimates do not guarantee future outcomes.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.