Liquidity Master
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «liquidity master for tradingview.pine» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
«Liquidity Master» — индикатор для TradingView, который визуализирует отложенные ордера (ликвидность) на графике цены. Он определяет стоп-ордера за подтверждёнными свингами и зоны отклонения фитилей, формирует из них пулы ликвидности и отображает их в виде глубинной лестницы рядом с ценой.
Индикатор отслеживает крупнейшие «стены» ликвидности с каждой стороны графика и тестирует их при достижении ценой: фиксирует, удержалась ли стена (цена откатилась), или пробита (цена закрылась через неё). Результаты тестов накапливаются и отображаются в информационной панели.
Пользователь может настраивать параметры обнаружения свингов, чувствительность к фитильным отклонениям, скорость устаревания пулов, геометрию лестницы, цвета, отображение стен, ценовой метки и панели. Доступны четыре условия оповещений для отслеживания ключевых событий на графике.
Настройки программы
| Настройка | Описание |
|---|---|
| pivIn | Количество баров с каждой стороны для подтверждения свинга. Стоп-ордера размещаются чуть за подтверждёнными свингами высоких и низких точек. |
| wickIn | Минимальная длина фитиля в единицах ATR, при которой фитиль распознаётся как зона отклонения ордеров. Пулы сохраняются до возврата цены. |
| halfIn | Количество баров, за которые половина пула ликвидности расходуется (пулы устаревают по мере снятия ордеров). |
| lookIn | Количество последних баров, на которых работает движок расчёта, для поддержания производительности. |
| posIn | Положение глубинной лестницы: «Over the last bars» — по последним барам (как профиль объёма), «Right of price» — справа от цены (требуется свободное место на шкале). |
| widthIn | Ширина глубинной лестницы в барах (горизонтальный размер). |
| spanIn | Количество последних баров, диапазон цен которых охватывает глубинная лестница (с отступом). |
| rowsIn | Количество строк (горизонтальных уровней) в глубинной лестнице. |
| themeIn | Цветовая тема лестницы и стен: «Mint and Pink», «Ice» или «Custom» (с ручным выбором цветов покупок и продаж). |
| cBidIn | Цвет отображения зон заявок (предложений покупки) ниже цены при выбранной теме «Custom». |
| cAskIn | Цвет отображения зон предложений (предложений продаж) выше цены при выбранной теме «Custom». |
| bright | Множитель яркости отрисовки лестницы и свечения стен. Допустимые значения от 1 до 5. |
| showWalls | Включает или отключает отображение горизонтальных линий стен на графике. |
| showNames | Включает или отключает отображение названий стен (sell wall / buy wall) рядом с ними на графике. |
| showPrice | Отображает ценовую метку текущей цены на лестнице. Видна только при положении лестницы справа от цены. |
| showPanel | Включает или отключает информационную панель с данными о стенах, балансе и тестах. |
| panelPos | Положение информационной панели на графике: верхний левый, верхний правый, нижний левый или нижний правый угол. |
| panelSize | Размер шрифта в информационной панели: малый, нормальный или большой. |
Поиск по коду файла
indicator("Liquidity Master", "Liquidity Master", overlay = true, max_boxes_count = 500, max_lines_count = 50, max_labels_count = 50, max_bars_back = 500)
grpE = "Liquidity"
pivIn = input.int(4, "Swing strength (bars)", minval = 2, maxval = 20, group = grpE, tooltip = "Stops rest just past a swing high or swing low. A swing needs this many lower highs or higher lows on each side.")
wickIn = input.float(0.45, "Wick rejection (ATR)", minval = 0.2, maxval = 2, step = 0.05, group = grpE, tooltip = "A wick at least this long shows orders that absorbed a push. They stay on the ladder until price trades back through them.")
halfIn = input.int(300, "Liquidity ages out over (bars)", minval = 50, maxval = 3000, step = 10, group = grpE, tooltip = "Half of a pool is gone after this many bars, because orders get pulled.")
lookIn = input.int(1500, "Bars to compute", minval = 300, maxval = 4000, step = 100, group = grpE, tooltip = "The engine runs on the most recent bars only, to keep the chart fast.")
grpL = "Ladder"
posIn = input.string("Over the last bars", "Ladder sits", options = ["Over the last bars", "Right of price"], group = grpL, tooltip = "Over the last bars draws the ladder across the most recent candles, like a volume profile. Right of price puts it in the empty space to the right, which needs room: drag the price scale to the left, or raise the right margin in the chart settings.")
widthIn = input.int(30, "Ladder width (bars)", minval = 10, maxval = 100, group = grpL)
spanIn = input.int(300, "Ladder covers (bars)", minval = 50, maxval = 2000, step = 10, group = grpL, tooltip = "The ladder spans the price range of this many recent bars, plus a margin. Match it to how many bars you keep on screen.")
rowsIn = input.int(80, "Rows", minval = 20, maxval = 100, group = grpL)
themeIn = input.string("Mint and Pink", "Colours", options = ["Mint and Pink", "Ice", "Custom"], group = grpL)
cBidIn = input.color(#00FFA3, "", group = grpL, inline = "c")
cAskIn = input.color(#FF3D71, "", group = grpL, inline = "c")
bright = input.int(3, "Brightness", minval = 1, maxval = 5, group = grpL)
showWalls = input.bool(true, "Wall lines", group = grpL, inline = "w")
showNames = input.bool(true, "Wall names", group = grpL, inline = "w")
showPrice = input.bool(true, "Price tag", group = grpL, inline = "w", tooltip = "The price tag only shows when the ladder sits right of price, the axis already has it otherwise.")
showPanel = input.bool(true, "Panel", group = grpL, inline = "p")
panelPos = input.string("Top right", "", options = ["Top left", "Top right", "Bottom left", "Bottom right"], group = grpL, inline = "p")
panelSize = input.string("Normal", "", options = ["Small", "Normal", "Large"], group = grpL, inline = "p")
[colBid, colAsk] = switch themeIn
"Mint and Pink" => [#00FFA3, #FF3D71]
"Ice" => [#7DD3FC, #C4B5FD]
=> [cBidIn, cAskIn]
color colPanel = #262B38
color colEdge = #2A2E39
int maxEv = 400 // pools kept at once
int maxRows = 100 // ladder rows available
float zoneATR = 0.75 // stops sit within three quarters of an ATR past a swing
float pivW = 1.6 // weight of the stops past a swing
float wickW = 0.5 // weight of a rejection wick, times its relative volume
int refreshEvery = 10 // bars between wall refreshes for the record
int keepRec = 10 // wall tests remembered
float brokeATR = 0.5 // a close this far past a wall breaks it
float heldATR = 0.5 // a close this far back from a wall means it held
int testBars = 60 // a test is dropped after this many bars without a verdict
int lineBack = 150 // how far the wall lines reach back
float wallAt = 0.5 // a wall must hold at least this share of the biggest row to be tracked
float atr = math.max(nz(ta.atr(14), high - low), syminfo.mintick)
float atrG = math.max(nz(ta.atr(50), atr), syminfo.mintick) // the slow one, for the ladder's geometry
float vAvg = ta.sma(nz(volume, 0), 50)
bool hasVol = not na(volume) and vAvg > 0
float vRel = hasVol ? math.min(volume / vAvg, 4.0) : 1.0
float ph = ta.pivothigh(high, pivIn, pivIn)
float pl = ta.pivotlow(low, pivIn, pivIn)
float hhSince = ta.highest(high, pivIn) // the bars after a swing high, by the time it confirms
float llSince = ta.lowest(low, pivIn)
bool active = bar_index > last_bar_index - lookIn
int nrow = math.min(rowsIn, maxRows)
float hhSpan = ta.highest(high, spanIn)
float llSpan = ta.lowest(low, spanIn)
float margin = math.max(1.5 * atrG, 0.08 * (hhSpan - llSpan))
float step = math.max(math.round(((hhSpan - llSpan + 2 * margin) / nrow) / syminfo.mintick) * syminfo.mintick, syminfo.mintick)
float base = math.floor((llSpan - margin) / step) * step // rows sit on a fixed grid, so they do not slide with every tick
float brightMul = 0.4 + 0.2 * bright
var evSide = array.new_int() // 1 above price (offers and buy stops), -1 below (bids and sell stops)
var evP0 = array.new_float()
var evP1 = array.new_float()
var evW = array.new_float()
var evBar = array.new_int()
var evExt = array.new_float() // the furthest price has traded into the zone since it was created
var rowS = array.new_float(maxRows, 0.0)
var recHeld = array.new_int() // 1 the wall held, 0 it broke
bool reachedUp = false
bool reachedDn = false
bool wallHeld = false
bool wallBroke = false
dropEv(int k) =>
array.remove(evSide, k)
array.remove(evP0, k)
array.remove(evP1, k)
array.remove(evW, k)
array.remove(evBar, k)
array.remove(evExt, k)
k
addEv(int side, float p0, float p1, float w, int atBar, float ext) =>
if array.size(evP0) >= maxEv
dropEv(0)
array.push(evSide, side)
array.push(evP0, p0)
array.push(evP1, p1)
array.push(evW, w)
array.push(evBar, atBar)
array.push(evExt, ext)
true
buildRows() =>
for r = 0 to maxRows - 1
array.set(rowS, r, 0.0)
int n = array.size(evP0)
if n > 0
for k = 0 to n - 1
int side = array.get(evSide, k)
float a0 = side == 1 ? math.max(array.get(evP0, k), array.get(evExt, k)) : array.get(evP0, k)
float a1 = side == 1 ? array.get(evP1, k) : math.min(array.get(evP1, k), array.get(evExt, k))
if a1 > a0
float w = array.get(evW, k) * math.pow(0.5, (bar_index - array.get(evBar, k)) / halfIn)
int r0 = math.max(math.floor((a0 - base) / step), 0)
int r1 = math.min(math.floor((a1 - base) / step), nrow - 1)
if r1 >= r0
for r = r0 to r1
float lo = base + r * step
float ov = math.min(a1, lo + step) - math.max(a0, lo)
if ov > 0
array.set(rowS, r, array.get(rowS, r) + w * ov / (a1 - a0))
float peak = 0.0
if nrow >= 3
float prev = array.get(rowS, 0)
for r = 0 to nrow - 1
float cur = array.get(rowS, r)
float nxt = r < nrow - 1 ? array.get(rowS, r + 1) : cur
float sm = 0.25 * prev + 0.5 * cur + 0.25 * nxt
prev := cur
array.set(rowS, r, sm)
peak := math.max(peak, sm)
peak
findWalls(float peak) =>
float upP = na
float upT = 0.0
float dnP = na
float dnT = 0.0
float nearUp = na
float nearDn = na
float sumUp = 0.0
float sumDn = 0.0
if peak > 0
for r = 0 to nrow - 1
float mid = base + (r + 0.5) * step
float t = array.get(rowS, r) / peak
if mid >= close + 0.3 * atr
sumUp += t
if t > upT
upT := t
upP := mid
if t >= 0.3 and na(nearUp)
nearUp := mid
else if mid <= close - 0.3 * atr
sumDn += t
if t > dnT
dnT := t
dnP := mid
if t >= 0.3
nearDn := mid
[upP, upT, dnP, dnT, nearUp, nearDn, sumUp, sumDn]
pushRec(int v) =>
array.push(recHeld, v)
if array.size(recHeld) > keepRec
array.shift(recHeld)
v
var float wallUpV = na // the walls as of the last refresh, for the record
var float wallDnV = na
var int testSide = 0
var float testP = na
var int testBar = 0
if active and barstate.isconfirmed
int i = 0
while i < array.size(evP0)
int side = array.get(evSide, i)
bool gone = bar_index - array.get(evBar, i) > 4 * halfIn
if side == 1
float ext = math.max(array.get(evExt, i), high)
array.set(evExt, i, ext)
gone := gone or ext >= array.get(evP1, i)
else
float ext = math.min(array.get(evExt, i), low)
array.set(evExt, i, ext)
gone := gone or ext <= array.get(evP0, i)
if gone
dropEv(i)
else
i += 1
if not na(ph) and hhSince < ph + zoneATR * atr
addEv(1, ph, ph + zoneATR * atr, pivW, bar_index - pivIn, math.max(hhSince, ph))
if not na(pl) and llSince > pl - zoneATR * atr
addEv(-1, pl - zoneATR * atr, pl, pivW, bar_index - pivIn, math.min(llSince, pl))
float uw = high - math.max(open, close)
float dw = math.min(open, close) - low
if uw >= wickIn * atr
addEv(1, math.max(open, close), high, wickW * vRel, bar_index, math.max(open, close))
if dw >= wickIn * atr
addEv(-1, low, math.min(open, close), wickW * vRel, bar_index, math.min(open, close))
if bar_index % refreshEvery == 0 and array.size(evP0) >= 15
float pk = buildRows()
[u, tu, d, td, nu, nd, su, sd] = findWalls(pk)
wallUpV := tu >= wallAt ? u : na
wallDnV := td >= wallAt ? d : na
if testSide == 0
if not na(wallUpV) and high >= wallUpV - step / 2
testSide := 1
testP := wallUpV
testBar := bar_index
wallUpV := na
reachedUp := true
else if not na(wallDnV) and low <= wallDnV + step / 2
testSide := -1
testP := wallDnV
testBar := bar_index
wallDnV := na
reachedDn := true
else
bool broke = testSide == 1 ? close > testP + brokeATR * atr : close < testP - brokeATR * atr
bool held = testSide == 1 ? close <= testP - heldATR * atr : close >= testP + heldATR * atr
if broke
pushRec(0)
wallBroke := true
testSide := 0
else if held
pushRec(1)
wallHeld := true
testSide := Показано первые 50% кода (символов: 15808)