OPEN-SOURCE SCRIPT
Premium Map Pro: Bayesian Probability Fan, Order Blocks

WHAT THIS IS
This indicator is a higher-timeframe "regime map," designed for a 2-hour chart (defaults tuned for micro silver futures, but every symbol and driver is an input). It answers three questions on one screen: what regime is the market in (trend, premium/discount, money flow), where are the levels that matter (displacement order blocks, equilibrium, VWAP), and what does recent history suggest happens next (a probability fan over the next 8 hours, with a percentage on each path).
HOW THE PREDICTION IS FORMED
The engine is a Bernoulli Naive Bayes classifier fit by maximum likelihood on a rolling window (default 500 bars). Each bar, 14 binary features are recorded — 8 from price/volume (2H trend vs EMA20, 4H trend, discount vs equilibrium, VWAP side, structure, volume vs average, volume rising, MFI above 50) and 6 from cross-asset drivers (gold, DXY, gold/silver ratio, copper, 2Y yield, a volatility index — all symbol inputs). For each feature, the script counts how often it coincided with the market rising vs falling over the following N bars (default 4 = 8 hours). Those frequencies are the maximum-likelihood estimates of each feature's predictive weight: features that predicted well get large log-likelihood ratios, useless ones converge to zero. The weights are re-estimated every bar, so the model adapts to regime changes with no manual tuning. The result is P(up), shown as the triangle and its percentage.
THE PROBABILITY FAN
The fan extends five dotted rays from the current close to five targets one horizon ahead: ±2 ATR, ±1 ATR (ATR scaled by √horizon), and flat. Each ray's percentage is the empirical frequency of that size of move in the training window, tilted by the model's current directional odds, renormalized to 100%. Ray thickness encodes probability. Read the shape, not just the lean: a fat middle ray means "drift expected"; fat outer rays with a thin middle mean "big move brewing, direction uncertain."
ORDER BLOCKS
A displacement bar (body > 1.5 ATR closing beyond the prior bar's extreme) marks the previous opposite-colored candle as an order block — supply above, demand below. Blocks born on above-average volume are tagged OB+ with a solid border. Blocks expire after a set lifespan (default 24h) or immediately when price closes through them (mitigation).
READING THE PANEL (bottom-right, top to bottom)
4H·8H — higher-timeframe trend agreement (green BULL / red BEAR / gray MIX). Hover for the daily trend.
P↑ — the model's probability of the market being higher in 8 hours. Green ≥ ~60, red ≤ ~40, gray = coin flip.
MAC — macro consensus from the six drivers, −5 (all hostile) to +5 (all supportive). Hover shows the drivers and a HI-VOL tag when the volatility index is elevated.
LOC — PREM/DISC: price above or below the 50% equilibrium of the recent swing range.
MFI — money flow IN/OUT (volume-weighted RSI). Red price bars with MFI drifting green is a classic accumulation divergence.
V-6h / V-4h / V-2h — the last three 2H bars: cell color = that bar's price direction, text = its volume vs the bar before (UP 2.3 = expanding). Red+UP = heavy selling; red+DN = selling drying up.
PLAY — trend × location playbook: BUY (bull trend + discount), SELL (bear trend + premium), WAIT otherwise.
KEY PARAMETERS
MLE horizon (bars ahead to predict) and training window; order-block displacement multiple, lifespan, and volume-quality threshold; equilibrium swing lookback; the six macro symbols (swap them to repurpose for any market — e.g., for gold use DXY, 10Y yield, real yields, breakevens, silver, GVZ); toggles for the fan, labels, and macro features.
HONEST LIMITATIONS
Probabilities are learned from recent history — after a news shock they need time to re-adapt, and on thin overnight volume they mean little. The Naive Bayes independence assumption makes extreme readings somewhat overconfident; treat 65% as a lean, not a promise. Values on the live bar update until it closes. This is a decision-support map, not a signal service, and nothing here is financial advice.
This indicator is a higher-timeframe "regime map," designed for a 2-hour chart (defaults tuned for micro silver futures, but every symbol and driver is an input). It answers three questions on one screen: what regime is the market in (trend, premium/discount, money flow), where are the levels that matter (displacement order blocks, equilibrium, VWAP), and what does recent history suggest happens next (a probability fan over the next 8 hours, with a percentage on each path).
HOW THE PREDICTION IS FORMED
The engine is a Bernoulli Naive Bayes classifier fit by maximum likelihood on a rolling window (default 500 bars). Each bar, 14 binary features are recorded — 8 from price/volume (2H trend vs EMA20, 4H trend, discount vs equilibrium, VWAP side, structure, volume vs average, volume rising, MFI above 50) and 6 from cross-asset drivers (gold, DXY, gold/silver ratio, copper, 2Y yield, a volatility index — all symbol inputs). For each feature, the script counts how often it coincided with the market rising vs falling over the following N bars (default 4 = 8 hours). Those frequencies are the maximum-likelihood estimates of each feature's predictive weight: features that predicted well get large log-likelihood ratios, useless ones converge to zero. The weights are re-estimated every bar, so the model adapts to regime changes with no manual tuning. The result is P(up), shown as the triangle and its percentage.
THE PROBABILITY FAN
The fan extends five dotted rays from the current close to five targets one horizon ahead: ±2 ATR, ±1 ATR (ATR scaled by √horizon), and flat. Each ray's percentage is the empirical frequency of that size of move in the training window, tilted by the model's current directional odds, renormalized to 100%. Ray thickness encodes probability. Read the shape, not just the lean: a fat middle ray means "drift expected"; fat outer rays with a thin middle mean "big move brewing, direction uncertain."
ORDER BLOCKS
A displacement bar (body > 1.5 ATR closing beyond the prior bar's extreme) marks the previous opposite-colored candle as an order block — supply above, demand below. Blocks born on above-average volume are tagged OB+ with a solid border. Blocks expire after a set lifespan (default 24h) or immediately when price closes through them (mitigation).
READING THE PANEL (bottom-right, top to bottom)
4H·8H — higher-timeframe trend agreement (green BULL / red BEAR / gray MIX). Hover for the daily trend.
P↑ — the model's probability of the market being higher in 8 hours. Green ≥ ~60, red ≤ ~40, gray = coin flip.
MAC — macro consensus from the six drivers, −5 (all hostile) to +5 (all supportive). Hover shows the drivers and a HI-VOL tag when the volatility index is elevated.
LOC — PREM/DISC: price above or below the 50% equilibrium of the recent swing range.
MFI — money flow IN/OUT (volume-weighted RSI). Red price bars with MFI drifting green is a classic accumulation divergence.
V-6h / V-4h / V-2h — the last three 2H bars: cell color = that bar's price direction, text = its volume vs the bar before (UP 2.3 = expanding). Red+UP = heavy selling; red+DN = selling drying up.
PLAY — trend × location playbook: BUY (bull trend + discount), SELL (bear trend + premium), WAIT otherwise.
KEY PARAMETERS
MLE horizon (bars ahead to predict) and training window; order-block displacement multiple, lifespan, and volume-quality threshold; equilibrium swing lookback; the six macro symbols (swap them to repurpose for any market — e.g., for gold use DXY, 10Y yield, real yields, breakevens, silver, GVZ); toggles for the fan, labels, and macro features.
HONEST LIMITATIONS
Probabilities are learned from recent history — after a news shock they need time to re-adapt, and on thin overnight volume they mean little. The Naive Bayes independence assumption makes extreme readings somewhat overconfident; treat 65% as a lean, not a promise. Values on the live bar update until it closes. This is a decision-support map, not a signal service, and nothing here is financial advice.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.