QUANTUM MARKET X-RAY
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «indicator quantum market x-ray for tradingview.pine» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
QUANTUM MARKET X-RAY (QMX) — это индикатор-оверлей для TradingView, написанный на Pine Script v6, который анализирует рыночную структуру на основе стандартных данных OHLCV. Программа рассчитывает технические показатели (ATR, относительный объём, импульс), определяет уровни ликвидности, зоны проскальзывания, ловушки, волны давления и энергетические смещения, отображая их графически на графике цены.
Индикатор включает панель мониторинга с оценками бычьего и медвежьего давления, обзором множественных таймфреймов и ключевыми уровнями. Все расчёты выполняются на закрытых барах, что исключает перерисовку. Многофункциональность достигается за счёт множества пользовательских настроек, управляющих отображением каждого модуля.
Продукт предоставляет систему оповещений TradingView для ключевых событий: проскальзывания ликвидности, ловушки, смещения, истощение и развороты давления. Все аналитические значения являются оценками и не являются финансовой рекомендацией.
Настройки программы
| Настройка | Описание |
|---|---|
| atrLen | Период расчёта индикатора среднего истинного диапазона (ATR), используемого для масштабирования зон и уровней. |
| swingLen | Количество баров с каждой стороны для определения пивотов (свинг-опор). Пивоты подтверждаются только после полного подтверждения правой стороны. |
| relVolLen | Период расчёта скользящего среднего объёма для определения относительного объёма. |
| glowOn | Включает многоуровневые светящиеся эффекты для графических объектов. |
| cBull | Цвет для бычьих (Bullish) неоновых элементов. |
| cCyan | Цвет для бычьих электрических элементов волн давления. |
| cBear | Цвет для медвежьих (Bearish) неоновых элементов. |
| cPurple | Цвет для медвежьих фиолетовых элементов волн давления. |
| cMagenta | Цвет для маркировки ликвидности в маджентовом оттенке. |
| cGold | Цвет для маркировки зон истощения в режиме Gold. |
| cAmber | Цвет для маркировки зон истощения в режиме Amber. |
| cSilver | Цвет для нейтральных серебряных элементов. |
| cGrey | Цвет для нейтральных серых элементов. |
| liqOn | Включает или отключает модуль интеллекта ликвидности (Liquidity Intelligence). |
| showBSL | Отображает уровни ликвидности покупателей (Buy-Side Liquidity, BSL) на графике. |
| showSSL | Отображает уровни ликвидности продавцов (Sell-Side Liquidity, SSL) на графике. |
| showLiqLbl | Отображает метки с оценкой силы уровней ликвидности. |
| showEq | Отображает соединительные линии между равными максимумами и минимумами. |
| eqTolAtr | Допуск равенства уровней ликвидности в кратных ATR для объединения близких уровней. |
| zoneAtr | Половина толщины зоны ликвидности в кратных ATR. |
| maxLevels | Максимальное количество активных уровней ликвидности на каждую сторону. |
| keepSwept | Количество уровней проскальзывания, сохраняемых в истории для каждой стороны. |
| sweepOn | Включает или отключает детектор проскальзывания ликвидности (Sweep Detector). |
| sweepCircle | Отображает круговые графические отпечатки (footprints) в местах проскальзывания. |
| sweepLabel | Отображает метки с оценкой силы проскальзывания. |
| sweepLink | Отображает соединительные линии от уровня ликвидности до свечи проскальзывания. |
| sweepCandle | Подсвечивает свечу, на которой произошло проскальзывание ликвидности. |
| minSweepStr | Минимальная сила проскальзывания для отображения маркера. |
| minPenAtr | Минимальное проникновение уровня ликвидности в кратных ATR для регистрации проскальзывания. |
| trapOn | Включает или отключает детектор ловушек Smart Money (Trap Detector). |
| trapBox | Отображает прямоугольные коробки для маркировки ловушек Smart Money. |
| trapLabel | Отображает текстовые метки внутри коробок ловушек. |
| trapLen | Период обзора для определения уровней пробития (breakout) при поиске ловушек. |
| trapWin | Количество баров (окно), в течение которого пробитие считается неудачным (ловушкой). |
| maxTraps | Максимальное количество одновременно отображаемых коробок ловушек. |
| pressOn | Включает или отключает модуль волн давления (Pressure Waves). |
| showBullWave | Отображает бычью волну давления циановым цветом. |
| showBearWave | Отображает медвежью волну давления фиолетовым цветом. |
| showCore | Отображает центральную линию волны давления. |
| showRev | Отображает маркеры разворота давления (Pressure Reversal). |
| pressLen | Период сглаживания импульса давления (EMA) для расчёта бычьего/медвежьего давления. |
| waveLen | Период EMA для расчёта центральной линии волны давления. |
| waveAmp | Амплитуда волн давления в кратных ATR. |
| dispOn | Включает или отключает модуль энергетического смещения (Displacement Energy). |
| dispOutline | Отображает светящиеся контуры свечей с энергетическим смещением. |
| dispTrail | Отображает энергетические следы (линии) между открытием и закрытием свечей смещения. |
| dispZoneOn | Отображает зоны смещения (Displacement Zones) в виде полупрозрачных прямоугольников. |
| dispMarker | Отображает направленные маркеры (треугольники) на графике для свечей с энергетическим смещением. |
| dispLabel | Отображает метки с оценкой энергии смещения рядом с соответствующими свечами. |
| dispMult | Минимальный размер тела свечи в кратных ATR для классификации как смещение. |
| dispVol | Минимальное значение относительного объёма (при наличии данных) для классификации свечи как смещение. |
| dispMinScore | Минимальный балл энергии смещения, при котором свеча классифицируется как смещение. |
| maxDisp | Максимальное количество одновременно отображаемых отпечатков смещения. |
| forOn | Включает или отключает модуль кандельной экспертизы (Candle Forensics). |
| fRejOn | Отображает маркеры сильных свечей-отказов (Strong Rejection Candles). |
| fWickOn | Отображает маркеры дисбаланса фитилей (Wick Imbalance). |
| fAbsOn | Отображает маркеры свечей с поглощением (Absorption-Like Candles). |
| fFailOn | Отображает маркеры неудачных аукционов (Failed Auction Proxies). |
| fExhOn | Отображает маркеры свечей с истощением импульса (Momentum Exhaustion). |
| fStrongOn | Отображает маркеры сильных бычьих или медвежьих свечей. |
| vacOn | Включает или отключает модуль ликвидности-вакуума (Liquidity Vacuum). |
| vacLabel | Отображает метки коридоров ликвидности (вакуумов) с информацией о входе, выходе и статусе. |
| vacMinAtr | Минимальный размер коридора в кратных ATR для формирования вакуума ликвидности. |
| vacLook | Количество баров истории для анализа перекрытия при расчёте коридоров вакуума. |
| vacInt | Максимальное допустимое значение исторического взаимодействия для формирования коридора вакуума. |
| maxVac | Максимальное количество одновременно отображаемых коридоров ликвидности (вакуумов). |
| exhOn | Включает или отключает модуль облаков истощения (Exhaustion Clouds). |
| exhEarlyOn | Отображает ранние (неподтверждённые) облака истощения при достижении порогового балла. |
| exhConfOn | Отображает только подтверждённые облака истощения, требующие минимального балла подтверждения. |
| exhEarlyThr | Минимальный балл для отображения раннего облака истощения. |
| exhConfThr | Минимальный балл для подтверждения облака истощения. |
| maxClouds | Максимальное количество одновременно отображаемых облаков истощения. |
| gravOn | Включает или отключает движок цены-гравитации (Price Gravity Engine). |
| gravZones | Отображает зоны притяжения и целевые поля для уровней гравитации. |
| gravConn | Отображает направленные соединительные линии от цены к целевым уровням гравитации. |
| gravLbl | Отображает метки с оценкой силы и расстоянием до целевых уровней гравитации. |
| gravTargets | Максимальное количество целевых уровней в каждом направлении (до 3). |
| usePDHL | Включает учёт предыдущего дневного максимума и минимума (Previous Day High/Low) в расчёте целей гравитации. |
| dashOn | Включает или отключает отображение панели мониторинга (дашборда) с аналитическими оценками. |
| dashPos | Позиция размещения панели мониторинга на графике. |
| tblSize | Размер текста в панели мониторинга. |
| mtfOn | Включает или отключает обзорную панель множественных таймфреймов в дашборде. |
| tf1 | Первый таймфрейм для обзора множественных таймфреймов в дашборде. |
| tf2 | Второй таймфрейм для обзора множественных таймфреймов в дашборде. |
| tf3 | Третий таймфрейм для обзора множественных таймфреймов в дашборде. |
| tf4 | Четвёртый таймфрейм для обзора множественных таймфреймов в дашборде. |
| tf5 | Пятый таймфрейм для обзора множественных таймфреймов в дашборде. |
Поиск по коду файла
indicator(title = "QUANTUM MARKET X-RAY (QMX)", shorttitle = "QMX", overlay = true, max_boxes_count = 500, max_lines_count = 500, max_labels_count = 500, max_polylines_count = 100, max_bars_back = 500)
const string G_GEN = "⚙ 00 · General"
const string G_COL = "🎨 01 · Colors"
const string G_LIQ = "02 · Liquidity Intelligence"
const string G_SWP = "03 · Liquidity Sweep Detector"
const string G_TRP = "04 · Smart Money Traps"
const string G_PRS = "05 · Market Pressure Waves"
const string G_DSP = "06 · Displacement Energy"
const string G_FOR = "07 · Candle Forensics"
const string G_VAC = "08 · Liquidity Vacuum"
const string G_EXH = "09 · Exhaustion Clouds"
const string G_GRV = "10 · Price Gravity Engine"
const string G_DSH = "11 · Quantum Dashboard"
atrLen = input.int(14, "ATR Length", minval = 2, maxval = 100, group = G_GEN)
swingLen = input.int(5, "Swing Pivot Length (bars each side)", minval = 2, maxval = 30, group = G_GEN, tooltip = "Pivots are confirmed only after this many bars on the right side → no future leakage.")
relVolLen = input.int(20, "Relative Volume Length", minval = 5, maxval = 100, group = G_GEN)
glowOn = input.bool(true, "Layered Glow Effects", group = G_GEN)
cBull = input.color(#00FF9C, "Bullish · Neon Green", group = G_COL)
cCyan = input.color(#00E5FF, "Bullish · Electric Cyan", group = G_COL)
cBear = input.color(#FF2D55, "Bearish · Neon Red", group = G_COL)
cPurple = input.color(#A855F7, "Bearish · Purple", group = G_COL)
cMagenta = input.color(#FF2BD6, "Liquidity · Magenta", group = G_COL)
cGold = input.color(#FFC400, "Exhaustion · Gold", group = G_COL)
cAmber = input.color(#FF9F1C, "Exhaustion · Amber", group = G_COL)
cSilver = input.color(#C0C6D4, "Neutral · Silver", group = G_COL)
cGrey = input.color(#6B7280, "Neutral · Grey", group = G_COL)
liqOn = input.bool(true, "Enable Liquidity Intelligence", group = G_LIQ)
showBSL = input.bool(true, "Draw Buy-Side Liquidity (BSL)", group = G_LIQ)
showSSL = input.bool(true, "Draw Sell-Side Liquidity (SSL)", group = G_LIQ)
showLiqLbl = input.bool(true, "Strength Labels", group = G_LIQ)
showEq = input.bool(true, "Equal Highs / Lows Connectors", group = G_LIQ)
eqTolAtr = input.float(0.15, "Equal Level Tolerance (× ATR)", minval = 0.02, maxval = 1.0, step = 0.01, group = G_LIQ)
zoneAtr = input.float(0.20, "Zone Half-Thickness (× ATR)", minval = 0.05, maxval = 1.0, step = 0.05, group = G_LIQ)
maxLevels = input.int(6, "Max Active Levels Per Side", minval = 2, maxval = 15, group = G_LIQ)
keepSwept = input.int(4, "Keep Swept Levels (history per side)", minval = 0, maxval = 20, group = G_LIQ)
sweepOn = input.bool(true, "Enable Sweep Detector", group = G_SWP)
sweepCircle = input.bool(true, "Circular Sweep Footprints", group = G_SWP)
sweepLabel = input.bool(true, "Sweep Strength Labels", group = G_SWP)
sweepLink = input.bool(true, "Connecting Lines To Swept Level", group = G_SWP)
sweepCandle = input.bool(true, "Highlight Sweep Candle", group = G_SWP)
minSweepStr = input.int(40, "Minimum Sweep Strength", minval = 0, maxval = 100, group = G_SWP)
minPenAtr = input.float(0.03, "Minimum Penetration (× ATR)", minval = 0.0, maxval = 1.0, step = 0.01, group = G_SWP)
trapOn = input.bool(true, "Enable Trap Detector", group = G_TRP)
trapBox = input.bool(true, "Trap Boxes", group = G_TRP)
trapLabel = input.bool(true, "Trap Labels", group = G_TRP)
trapLen = input.int(20, "Range Lookback For Breakouts", minval = 5, maxval = 100, group = G_TRP)
trapWin = input.int(6, "Failure Window (bars)", minval = 2, maxval = 20, group = G_TRP)
maxTraps = input.int(6, "Max Trap Boxes", minval = 1, maxval = 20, group = G_TRP)
pressOn = input.bool(true, "Enable Pressure Waves", group = G_PRS)
showBullWave = input.bool(true, "Bullish Pressure Wave (cyan)", group = G_PRS)
showBearWave = input.bool(true, "Bearish Pressure Wave (purple)", group = G_PRS)
showCore = input.bool(true, "Wave Core Line", group = G_PRS)
showRev = input.bool(true, "Pressure Reversal Markers", group = G_PRS)
pressLen = input.int(8, "Pressure Smoothing", minval = 2, maxval = 50, group = G_PRS)
waveLen = input.int(21, "Wave Core Length", minval = 5, maxval = 100, group = G_PRS)
waveAmp = input.float(1.2, "Wave Amplitude (× ATR)", minval = 0.2, maxval = 5.0, step = 0.1, group = G_PRS)
dispOn = input.bool(true, "Enable Displacement Energy", group = G_DSP)
dispOutline = input.bool(true, "Glowing Candle Outlines", group = G_DSP)
dispTrail = input.bool(true, "Energy Trails", group = G_DSP)
dispZoneOn = input.bool(true, "Displacement Zones", group = G_DSP)
dispMarker = input.bool(true, "Directional Markers", group = G_DSP)
dispLabel = input.bool(true, "Strength Labels", group = G_DSP)
dispMult = input.float(1.3, "Min Body (× ATR)", minval = 0.5, maxval = 5.0, step = 0.1, group = G_DSP)
dispVol = input.float(1.2, "Min Relative Volume (if volume exists)", minval = 0.5, maxval = 5.0, step = 0.1, group = G_DSP)
dispMinScore = input.int(45, "Min Energy Score", minval = 0, maxval = 100, group = G_DSP)
maxDisp = input.int(12, "Max Displacement Footprints", minval = 2, maxval = 40, group = G_DSP)
forOn = input.bool(true, "Enable Candle Forensics", group = G_FOR)
fRejOn = input.bool(true, "Strong Rejection Candles", group = G_FOR)
fWickOn = input.bool(false, "Wick Imbalance", group = G_FOR)
fAbsOn = input.bool(true, "Absorption-Like Candles", group = G_FOR)
fFailOn = input.bool(true, "Failed Auction Proxies", group = G_FOR)
fExhOn = input.bool(true, "Momentum Exhaustion Candles", group = G_FOR)
fStrongOn = input.bool(false, "Strong Bullish / Bearish Candles", group = G_FOR)
vacOn = input.bool(true, "Enable Liquidity Vacuum", group = G_VAC)
vacLabel = input.bool(true, "Vacuum Labels (Entry / Exit / Status)", group = G_VAC)
vacMinAtr = input.float(0.40, "Min Corridor Size (× ATR)", minval = 0.1, maxval = 3.0, step = 0.05, group = G_VAC)
vacLook = input.int(40, "Historical Overlap Lookback", minval = 10, maxval = 200, group = G_VAC)
vacInt = input.float(2.5, "Max Historical Interaction", minval = 0.0, maxval = 20.0, step = 0.5, group = G_VAC)
maxVac = input.int(6, "Max Vacuum Corridors", minval = 1, maxval = 20, group = G_VAC)
exhOn = input.bool(true, "Enable Exhaustion Clouds", group = G_EXH)
exhEarlyOn = input.bool(true, "Early Exhaustion Clouds", group = G_EXH)
exhConfOn = input.bool(true, "Confirmed Exhaustion Clouds", group = G_EXH)
exhEarlyThr = input.int(45, "Early Exhaustion Score", minval = 20, maxval = 100, group = G_EXH)
exhConfThr = input.int(32, "Confirmation Min Score", minval = 10, maxval = 100, group = G_EXH)
maxClouds = input.int(4, "Max Clouds", minval = 1, maxval = 10, group = G_EXH)
gravOn = input.bool(true, "Enable Price Gravity Engine", group = G_GRV)
gravZones = input.bool(true, "Attraction Zones / Target Fields", group = G_GRV)
gravConn = input.bool(true, "Directional Connectors", group = G_GRV)
gravLbl = input.bool(true, "Target Strength / Distance Labels", group = G_GRV)
gravTargets = input.int(3, "Targets Per Direction (max 3)", minval = 1, maxval = 3, group = G_GRV)
usePDHL = input.bool(true, "Include Previous Day High / Low", group = G_GRV)
dashOn = input.bool(true, "Show Dashboard", group = G_DSH)
dashPos = input.string(position.top_right, "Position", options = [position.top_right, position.top_left, position.bottom_right, position.bottom_left, position.middle_right, position.middle_left], group = G_DSH)
tblSize = input.string(size.small, "Text Size", options = [size.tiny, size.small, size.normal], group = G_DSH)
mtfOn = input.bool(true, "Multi-Timeframe Overview", group = G_DSH)
keyOn = input.bool(true, "Key Levels Section", group = G_DSH)
tf1 = input.timeframe("5", "MTF Row 1", group = G_DSH)
tf2 = input.timeframe("15", "MTF Row 2", group = G_DSH)
tf3 = input.timeframe("60", "MTF Row 3", group = G_DSH)
tf4 = input.timeframe("240", "MTF Row 4", group = G_DSH)
tf5 = input.timeframe("D", "MTF Row 5", group = G_DSH)
type Level
float price
int bar
bool isHigh
int touches = 1
float strength
float half
box bx
box gl
line ln
label lb
type Zone
box bx
box gl
line ln
line ln2
label lb
label lb2
label lb3
polyline pl
polyline pl2
float top
float bot
int dir
int t0
float score
float fillPct
float fillLvl
bool active = true
method kill(Level this) =>
if not na(this.bx)
box.delete(this.bx)
this.bx := na
if not na(this.gl)
box.delete(this.gl)
this.gl := na
if not na(this.ln)
line.delete(this.ln)
this.ln := na
if not na(this.lb)
label.delete(this.lb)
this.lb := na
true
method kill(Zone this) =>
if not na(this.bx)
box.delete(this.bx)
this.bx := na
if not na(this.gl)
box.delete(this.gl)
this.gl := na
if not na(this.ln)
line.delete(this.ln)
this.ln := na
if not na(this.ln2)
line.delete(this.ln2)
this.ln2 := na
if not na(this.lb)
label.delete(this.lb)
this.lb := na
if not na(this.lb2)
label.delete(this.lb2)
this.lb2 := na
if not na(this.lb3)
label.delete(this.lb3)
this.lb3 := na
if not na(this.pl)
polyline.delete(this.pl)
this.pl := na
if not na(this.pl2)
polyline.delete(this.pl2)
this.pl2 := na
true
f_clamp(float x, float lo, float hi) =>
math.max(lo, math.min(hi, x))
f_core(int aLen, int pLen, int vLen) =>
float a = ta.atr(aLen)
float aS = math.max(nz(a, syminfo.mintick * 10), syminfo.mintick)
float r = high - low
float b = math.abs(close - open)
float u = high - math.max(open, close)
float lw = math.min(open, close) - low
float vS = ta.sma(nz(volume), vLen)
bool hv = ta.cum(nz(volume)) > 0
float rv = hv and vS > 0 ? nz(volume) / vS : 1.0
float cp = r > 0 ? (close - low) / r : 0.5
float momUp = f_clamp(nz((close - close[3]) / (aS * 3.0)), 0.0, 1.0)
float momDn = f_clamp(nz((close[3] - close) / (aS * 3.0)), 0.0, 1.0)
float rW = f_clamp(r / aS, 0.3, 2.0)
float vW = f_clamp(rv, 0.5, 2.0)
float bullRaw = 0.35 * (close > open and r > 0 ? b / r : 0.0) + 0.30 * cp + 0.15 * (r > 0 ? lw / r : 0.0) + 0.20 * momUp
float bearRaw = 0.35 * (close < open and r > 0 ? b / r : 0.0) + 0.30 * (1.0 - cp) + 0.15 * (r > 0 ? u / r : 0.0) + 0.20 * momDn
float bE = ta.ema(bullRaw * rW * vW, pLen)
float rE = ta.ema(bearRaw * rW * vW, pLen)
float t = bE + rE
float n = t > 0 ? (bE - rE) / t : 0.0
[aS, bE, rE, n, rv]
f_htf() =>
[a, bE, rE, n, rv] = f_core(atrLen, pressLen, relVolLen)
float mid = ta.ema(hl2, waveLen)
float slope = mid - mid[3]
float aAvg = ta.sma(a, 50)
float ratio = aAvg > 0 ? a / aAvg : 1.0
float bd = math.abs(close - open)
float rg = high - low
bool disp = rg > 0 and bd >= dispMult * a and bd / rg >= 0.6
float dispR = ta.highest(disp ? 1.0 : 0.0, 5)
[n[1], slope[1], ratio[1], dispR[1]]
f_mtf(string tf) =>
request.security(syminfo.tickerid, tf, f_htf(), lookahead = barmerge.lookahead_on)
f_cnt(array<int> a, int within) =>
int c = 0
int n = a.size()
if n > 0
for i = 0 to n - 1
if bar_index - a.get(i) <= within
c += 1
c
f_push(array<int> a) =>
a.push(bar_index)
if a.size() > 30
a.shift()
true
f_trimZones(array<Zone> arr, int maxN) =>
while arr.size() > maxN
Zone o = arr.shift()
o.kill()
true
f_topIdx(array<float> a) =>
int idx = -1
float m = 0.0
int n = a.size()
if n > 0
for i = 0 to n - 1
if a.get(i) > m
m := a.get(i)
idx := i
idx
f_bar(float pct, int n) =>
int f = int(math.round(f_clamp(pct, 0.0, 100.0) / 100.0 * n))
str.repeat("█", f) + str.repeat("░", n - f)
f_tfName(int s) =>
s < 3600 ? str.tostring(int(s / 60)) + "m" : s < 86400 ? str.tostring(int(s / 3600)) + "H" : s < 604800 ? str.tostring(int(s / 86400)) + "D" : s < 2592000 ? str.tostring(int(s / 604800)) + "W" : "1M"
f_mtfState(float n, float sl, float ra, float di) =>
di > 0 ? "Expansion" : ra < 0.75 ? "Consolidation" : n > 0.12 and sl < 0 ? "Recovery" : n < -0.12 and sl > 0 ? "Pullback" : math.abs(n) >= 0.12 ? "Trend" : "Consolidation"
[atrV, bullE, bearE, net, relVol] = f_core(atrLen, pressLen, relVolLen)
bool hasVol = ta.cum(nz(volume)) > 0
float rng = high - low
float body = math.abs(close - open)
float upW = high - math.max(open, close)
float loW = math.min(open, close) - low
float closePos = rng > 0 ? (close - low) / rng : 0.5
float bodyAtr = body / atrV
float uwr = rng > 0 ? upW / rng : 0.0
float lwr = rng > 0 ? loW / rng : 0.0
float totE = bullE + bearE
float bullShare = totE > 0 ? bullE / totE : 0.5
int barMs = math.max(timeframe.in_seconds() * 1000, 1000)
float phV = ta.pivothigh(high, swingLen, swingLen)
float plV = ta.pivotlow(low, swingLen, swingLen)
float hiN = ta.highest(high, trapLen)
float loN = ta.lowest(low, trapLen)
float hi20 = ta.highest(high, 20)
float lo20 = ta.lowest(low, 20)
float hh10 = ta.highest(high, 10)
float ll10 = ta.lowest(low, 10)
float avgUw = ta.sma(uwr, 3)
float avgLw = ta.sma(lwr, 3)
float rngAvg5 = ta.sma(rng, 5)
float atrRank = ta.percentrank(atrV, 100)
float waveMid = ta.ema(hl2, waveLen)
var int pState = 0
int pPrev = pState
if net > 0.10
pState := 1
else if net < -0.10
pState := -1
bool pressRevUp = pState == 1 and pPrev == -1
bool pressRevDn = pState == -1 and pPrev == 1
bool pressWeak = (net > 0.10 and net < net[3] - 0.04) or (net < -0.10 and net > net[3] + 0.04)
float amp0 = atrV * waveAmp
float bullAmp = ta.ema(amp0 * (0.25 + bullShare), 3)
float bearAmp = ta.ema(amp0 * (0.25 + (1.0 - bullShare)), 3)
bool rawUp = close > open and rng > 0 and bodyAtr >= dispMult and body / rng >= 0.6 and closePos >= 0.70 and (not hasVol or relVol >= dispVol)
bool rawDn = close < open and rng > 0 and bodyAtr >= dispMult and body / rng >= 0.6 and closePos <= 0.30 and (not hasVol or relVol >= dispVol)
float dirPos = rawUp ? closePos : 1.0 - closePos
float dispScore = 35.0 * f_clamp(bodyAtr / (dispMult * 1.8), 0.0, 1.0) + 25.0 * (hasVol ? f_clamp(relVol / 2.5, 0.0, 1.0) : 0.5) + 25.0 * dirPos + 15.0 * f_clamp(rng / atrV / (dispMult * 2.0), 0.0, 1.0)
bool dispUp = dispOn and rawUp and dispScore >= dispMinScore
bool dispDn = dispOn and rawDn and dispScore >= dispMinScore
var float energy = 0.0
energy := math.max((dispUp or dispDn) ? dispScore : 0.0, energy * 0.88)
bool fRejBear = rng >= 0.6 * atrV and uwr >= 0.60 and closePos <= 0.35
bool fRejBull = rng >= 0.6 * atrV and lwr >= 0.60 and closePos >= 0.65
bool fWickBull = not fRejBull and rng >= 0.5 * atrV and loW >= 3.0 * math.max(upW, syminfo.mintick) and lwr >= 0.40
bool fWickBear = not fRejBear and rng >= 0.5 * atrV and upW >= 3.0 * math.max(loW, syminfo.mintick) and uwr >= 0.40
bool fAbsorb = hasVol and rng > 0 and relVol >= 1.6 and rng <= 0.8 * atrV and body / rng <= 0.40
bool fAbsBull = fAbsorb and closePos >= 0.5
bool fAbsBear = fAbsorb and closePos < 0.5
bool fFailUp = rng > 0 and high > hh10[1] and close < hh10[1] and closePos < 0.40 and (hasVol ? relVol <= 1.1 : bodyAtr < 0.5)
bool fFailDn = rng > 0 and low < ll10[1] and close > ll10[1] and closePos > 0.60 and (hasVol ? relVol <= 1.1 : bodyAtr < 0.5)
bool fMomExhUp = (close - close[3]) >= 1.5 * atrV and body < body[1] and upW > body
bool fMomExhDn = (close[3] - close) >= 1.5 * atrV and body < body[1] and loW > body
bool fStrongUp = close > open and rng > 0 and bodyAtr >= 0.8 and body / rng >= 0.65 and not rawUp
bool fStrongDn = close < open and rng > 0 and bodyAtr >= 0.8 and body / rng >= 0.65 and not rawDn
var float lastPH = na
var float prevPH = na
var float lastPL = na
var float prevPL = na
var float lastPHnet = na
var float prevPHnet = na
var float lastPLnet = na
var float prevPLnet = na
var int phConf = 0
var int plConf = 0
if barstate.isconfirmed and not na(phV)
prevPH := lastPH
prevPHnet := lastPHnet
lastPH := phV
lastPHnet := nz(net[swingLen])
phConf := bar_index
if barstate.isconfirmed and not na(plV)
prevPL := lastPL
prevPLnet := lastPLnet
lastPL := plV
lastPLnet := nz(net[swingLen])
plConf := bar_index
float posN = hi20 > lo20 ? (close - lo20) / (hi20 - lo20) : 0.5
bool divBear = not na(lastPH) and not na(prevPH) and lastPH > prevPH and lastPHnet < prevPHnet - 0.05 and bar_index - phConf <= 25
bool divBull = not na(lastPL) and not na(prevPL) and lastPL < prevPL and lastPLnet > prevPLnet + 0.05 and bar_index - plConf <= 25
float exUa = posN >= 0.85 ? 25.0 : posN >= 0.70 ? 12.0 : 0.0
float exUb = divBear ? 25.0 : 0.0
float exUc = (net > 0.05 and net < net[3] - 0.04) ? 20.0 : 0.0
float exUd = 20.0 * f_clamp(avgUw / 0.5, 0.0, 1.0)
float exUe = hasVol ? ((relVol >= 1.3 and bodyAtr < 0.7) ? 10.0 : 0.0) : (rng < rngAvg5 * 0.8 ? 6.0 : 0.0)
float exhUpScore = posN >= 0.70 ? exUa + exUb + exUc + exUd + exUe : 0.0
float exDa = posN <= 0.15 ? 25.0 : posN <= 0.30 ? 12.0 : 0.0
float exDb = divBull ? 25.0 : 0.0
float exDc = (net < -0.05 and net > net[3] + 0.04) ? 20.0 : 0.0
float exDd = 20.0 * f_clamp(avgLw / 0.5, 0.0, 1.0)
float exDe = hasVol ? ((relVol >= 1.3 and bodyAtr < 0.7) ? 10.0 : 0.0) : (rng < rngAvg5 * 0.8 ? 6.0 : 0.0)
float exhDnScore = posN <= 0.30 ? exDa + exDb + exDc + exDd + exDe : 0.0
float exhNow = math.max(exhUpScore, exhDnScore)
[pdh, pdl] = request.security(syminfo.tickerid, "D", [high[1], low[1]], lookahead = barmerge.lookahead_on)
int s1 = timeframe.in_seconds(tf1)
int s2 = timeframe.in_seconds(tf2)
int s3 = timeframe.in_seconds(tf3)
int s4 = timeframe.in_seconds(tf4)
int s5 = timeframe.in_seconds(tf5)
[m1n, m1s, m1r, m1d] = f_mtf(tf1)
[m2n, m2s, m2r, m2d] = f_mtf(tf2)
[m3n, m3s, m3r, m3d] = f_mtf(tf3)
[m4n, m4s, m4r, m4d] = f_mtf(tf4)
[m5n, m5s, m5r, m5d] = f_mtf(tf5)
var array<Level> bslArr = array.new<Level>()
var array<Level> sslArr = array.new<Level>()
var array<Level> bslDone = array.new<Level>()
var array<Level> sslDone = array.new<Level>()
var array<Zone> sweepFx = array.new<Zone>()
var array<Zone> trapFx = array.new<Zone>()
var array<Zone> dispFx = array.new<Zone>()
var array<Zone> dZones = array.new<Zone>()
var array<Zone> vacs = array.new<Zone>()
var array<Zone> clouds = array.new<Zone>()
var array<Zone> gravFx = array.new<Zone>()
var array<int> evSwBull = array.new<int>()
var array<int> evSwBear = array.new<int>()
var array<int> evTrapBuy = array.new<int>() // trapped buyers (bearish consequence)
var array<int> evTrapSell = array.new<int>() // trapped sellers (bullish consequence)
var array<int> evDispUp = array.new<int>()
var array<int> evDispDn = array.new<int>()
var array<int> evExhUp = array.new<int>() // bullish move exhausted (gold)
var array<int> evExhDn = array.new<int>() // bearish move exhausted (purple)
var bool bkUp = false
var float bkUpLvl = na
var int bkUpBar = 0
var float bkUpExt = na
var bool bkDn = false
var float bkDnLvl = na
var int bkDnBar = 0
var float bkDnExt = na
var int exhUpSt = 0
var int exhUpBar = 0
var int exhUpLast = -1000
var Zone exhUpCloud = na
var int exhDnSt = 0
var int exhDnBar = 0
var int exhDnLast = -1000
var Zone exhDnCloud = na
var int lastVacUp = -1000
var int lastVacDn = -1000
var bool tblInit = false
f_lvlText(Level l) =>
string kind = l.touches >= 3 ? (l.isHigh ? "BSL Cluster ×" : "SSL Cluster ×") + str.tostring(l.touches) : l.touches == 2 ? (l.isHigh ? "BSL · Equal Highs" : "SSL · Equal Lows") : (l.isHigh ? "BSL Zone" : "SSL Zone")
kind + "\nStrength: " + str.tostring(math.round(l.strength))
f_addLevel(array<Level> arr, bool isHigh, float px, int bar, float vN, float wN) =>
float tol = atrV * eqTolAtr
bool merged = false
color c = isHigh ? cBear : cBull
bool draw = isHigh ? showBSL : showSSL
int n = arr.size()
if n > 0
for i = 0 to n - 1
Level l = arr.get(i)
if not merged and math.abs(l.price - px) <= tol
merged := true
l.touches := l.touches + 1
l.price := isHigh ? math.max(l.price, px) : math.min(l.price, px)
l.strength := math.min(100.0, l.strength + 14.0 + 6.0 * vN)
if not na(l.bx)
box.set_top(l.bx, l.price + l.half)
box.set_bottom(l.bx, l.price - l.half)
if not na(l.gl)
box.set_top(l.gl, l.price + l.half * 2.4)
box.set_bottom(l.gl, l.price - l.half * 2.4)
if draw and showEq
if na(l.ln)
l.ln := line.new(l.bar, l.price, bar, l.price, color = color.new(c, 30), style = line.style_dotted, width = 1)
else
line.set_y1(l.ln, l.price)
line.set_y2(l.ln, l.price)
line.set_x2(l.ln, bar)
if not na(l.lb)
label.set_text(l.lb, f_lvlText(l))
label.set_y(l.lb, isHigh ? l.price + l.half : l.price - l.half)
if not merged
float st = math.min(100.0, 30.0 + 20.0 * vN + 15.0 * wN)
Level nl = Level.new(price = px, bar = bar, isHigh = isHigh, touches = 1, strength = st, half = atrV * zoneAtr)
if draw
if glowOn
nl.gl := box.new(left = bar, top = px + nl.half * 2.4, right = bar_index, bottom = px - nl.half * 2.4, border_color = color.new(c, 85), border_width = 3, extend = extend.right, bgcolor = color.new(c, 93))
nl.bx := box.new(left = bar, top = px + nl.half, right = bar_index, bottom = px - nl.half, border_color = color.new(c, 25), border_width = 1, extend = extend.right, bgcolor = color.new(c, 80))
if showLiqLbl
nl.lb := label.new(math.min(bar + 3, bar_index), isHigh ? px + nl.half : px - nl.half, f_lvlText(nl), style = isHigh ? label.style_label_down : label.style_label_up, color = color.new(#0B0F1C, 15), textcolor = c, size = size.small)
arr.push(nl)
if arr.size() > maxLevels
Level old = arr.shift()
old.kill()
true
f_sweepScan(array<Level> arr, array<Level> done, bool isHigh) =>
float best = 0.0
float bestPx = na
int bestBar = 0
bool bestRej = false
color c = isHigh ? cBear : cBull
int n = arr.size()
if n > 0
for i = n - 1 to 0
Level l = arr.get(i)
float pen = isHigh ? high - l.price : l.price - low
bool back = isHigh ? close < l.price : close > l.price
bool beyond = isHigh ? close > l.price : close < l.price
if pen > atrV * minPenAtr and back
float wickBack = rng > 0 ? (isHigh ? high - close : close - low) / rng : 0.0
float penSc = 25.0 * f_clamp(pen / (atrV * 0.5), 0.0, 1.0)
float rejSc = 30.0 * f_clamp(wickBack, 0.0, 1.0)
float backSc = 15.0 * f_clamp(math.abs(l.price - close) / (atrV * 0.5), 0.0, 1.0)
float volSc = hasVol ? 15.0 * f_clamp(relVol / 2.0, 0.0, 1.0) : 7.0
float lvSc = 15.0 * l.strength / 100.0
float sc = penSc + rejSc + backSc + volSc + lvSc
if sc > best
best := sc
bestPx := l.price
bestBar := l.bar
bestRej := wickBack >= 0.5
if not na(l.bx)
box.set_extend(l.bx, extend.none)
box.set_right(l.bx, bar_index)
box.set_bgcolor(l.bx, color.new(c, 92))
box.set_border_style(l.bx, line.style_dashed)
if not na(l.gl)
box.set_extend(l.gl, extend.none)
box.set_right(l.gl, bar_index)
if not na(l.lb)
label.delete(l.lb)
l.lb := na
if keepSwept == 0
l.kill()
else
done.push(l)
if done.size() > keepSwept
Level o = done.shift()
o.kill()
arr.remove(i)
else if beyond
l.kill()
arr.remove(i)
[best, bestPx, bestBar, bestRej]
f_drawSweep(bool bearish, float sc, float lvlPx, int lvlBar, bool rej) =>
Zone z = Zone.new(dir = bearish ? -1 : 1, t0 = bar_index, score = sc)
color c = bearish ? cBear : cBull
float y = bearish ? high : low
float off = atrV * 0.30
if sweepCircle
if glowOn
z.lb := label.new(bar_index, y, "", style = label.style_circle, color = color.new(c, 80), size = size.large)
z.lb2 := label.new(bar_index, y, "", style = label.style_circle, color = color.new(c, 10), size = size.tiny)
if sweepLink
z.ln := line.new(lvlBar, lvlPx, bar_index, lvlPx, color = color.new(c, 35), style = line.style_dotted, width = 1)
z.ln2 := line.new(bar_index, lvlPx, bar_index, y, color = color.new(c, 10), style = line.style_solid, width = 2)
if sweepLabel
z.lb3 := label.new(bar_index, y + (bearish ? off : -off), (bearish ? "Bearish Sweep" : "Bullish Sweep") + (rej ? " ⟲" : "") + "\nSQ: " + str.tostring(math.round(sc)), style = bearish ? label.style_label_down : label.style_label_up, color = color.new(#0B0F1C, 15), textcolor = c, size = size.small)
z
f_drawTrap(bool buyers, int leftBar, float top, float bot, float sc) =>
Zone z = Zone.new(dir = buyers ? -1 : 1, t0 = bar_index, score = sc)
color c = buyers ? cBear : cBull
float pad = atrV * 0.15
int lx = math.max(leftBar - 1, 0)
if trapBox
if glowOn
z.gl := box.new(left = lx, top = top + pad * 1.6, right = bar_index + 4, bottom = bot - pad * 1.6, border_color = color.new(c, 80), border_width = 4, bgcolor = na)
z.bx := box.new(left = lx, top = top + pad, right = bar_index + 4, bottom = bot - pad, border_color = color.new(c, 15), border_width = 2, bgcolor = color.new(c, 86), text = trapLabel ? (buyers ? "Trapped Buyers ⚠" : "Trapped Sellers ⚠") : "", text_color = c, text_size = size.small, text_halign = text.align_left, text_valign = text.align_top)
z
f_drawDisp(bool bull, float sc) =>
Zone z = Zone.new(dir = bull ? 1 : -1, t0 = bar_index, score = sc)
color c = bull ? cBull : cBear
int hw = int(barMs * 0.46)
float pad = atrV * 0.08
if dispOutline
if glowOn
z.gl := box.new(left = time - hw, top = high + pad * 2.0, right = time + hw, bottom = low - pad * 2.0, border_color = color.new(c, 70), border_width = 4, xloc = xloc.bar_time, bgcolor = color.new(c, 92))
z.bx := box.new(left = time - hw, top = high + pad, right = time + hw, bottom = low - pad, border_color = color.new(c, 5), border_width = 1, xloc = xloc.bar_time, bgcolor = na)
if dispTrail
z.ln2 := line.new(bar_index - 1, open, bar_index, close, color = color.new(c, 75), width = 7)
z.ln := line.new(bar_index - 1, open, bar_index, close, color = color.new(c, 0), width = 2)
if dispLabel
z.lb := label.new(bar_index, bull ? low - pad * 5.0 : high + pad * 5.0, "⚡" + str.tostring(math.round(sc)), style = bull ? label.style_label_up : label.style_label_down, color = color.new(c, 78), textcolor = color.new(cSilver, 0), size = size.tiny)
z
f_drawDZone(bool bull) =>
Zone z = Zone.new(dir = bull ? 1 : -1, t0 = bar_index, top = math.max(open, close), bot = math.min(open, close))
color c = bull ? cBull : cBear
z.bx := box.new(left = bar_index, top = z.top, right = bar_index + 1, bottom = z.bot, border_color = color.new(c, 55), border_width = 1, border_style = line.style_dashed, extend = extend.right, bgcolor = color.new(c, 90), text = "DISP", text_color = color.new(c, 30), text_size = size.tiny, text_halign = text.align_right)
z
f_vacText(Zone z) =>
string st = z.fillPct >= 0.999 ? "FILLED ✓" : z.fillPct <= 0.02 ? "UNFILLED" : "PARTIAL " + str.tostring(math.round(z.fillPct * 100)) + "%"
float en = z.dir == 1 ? z.bot : z.top
float ex = z.dir == 1 ? z.top : z.bot
(z.dir == 1 ? "VACUUM ▲ " : "VACUUM ▼ ") + st + "\nEntry " + str.tostring(en, format.mintick) + " → Exit " + str.tostring(ex, format.mintick)
f_interaction(float bot, float top) =>
float s = 0.0
float sz = math.max(top - bot, syminfo.mintick)
for i = 3 to 3 + vacLook
float ov = math.min(top, high[i]) - math.max(bot, low[i])
if ov > 0
float w = hasVol ? f_clamp(nz(relVol[i], 1.0), 0.5, 2.0) : 1.0
s += math.min(ov / sz, 1.0) * w
s
f_drawVac(bool up, float top, float bot, float sc) =>
Zone z = Zone.new(dir = up ? 1 : -1, t0 = bar_index, top = top, bot = bot, score = sc, fillPct = 0.0, fillLvl Показано первые 50% кода (символов: 42352)