← К каталогу
Исходный код · ID 4198

High Volume Pivot Support & Resistance Zones [BigBeluga]

indicator_high_volume_pivot_support_&_resistance_zones_bigbeluga.pine
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

Индикатор анализирует график ценовых данных и выявляет потенциальные зоны поддержки и сопротивления на основе разворотов цены и объёмной подтверждённости. При обнаружении значимого пивота с повышенным объёмом строится зональная область в виде прямоугольника с цветовой заливкой и границей, а также отображается объёмный дельта-анализ внутри зоны. Зоны динамически обновляются по мере движения цены: при пробое зоны сопротивления снизу вверх или зоны поддержки сверху вниз происходит смена их визуального стиля и цвета, что сигнализирует об изменении роли уровня. Индикатор также отображает графические маркеры пробоев, удержаний и перетестов зон, работает поверх основного графика и использует встроенные средства Pine Script для расчёта скользящих средних объёма, ATR и обнаружения пивотов.

Настройки программы

НастройкаОписание
resLen Длина пивота сопротивления — Количество баров до и после пика, необходимое для подтверждения структурного разворота сопротивления.
supLen Длина пивота поддержки — Количество баров до и после впадины, необходимое для подтверждения структурного разворота поддержки.
volAvgLen Длина MA объёма — Период расчёта скользящего среднего объёма, используемого в качестве базового уровня для сравнения.
volMult Множитель порога объёма — Множитель, применяемый к базовому среднему объёму. Бар пивота должен превысить это значение для подтверждения.
resColor Цвет зоны сопротивления — Цвет фона активной зоны сопротивления.
resLine Цвет линии сопротивления — Цвет границы и текста для зон и маркеров сопротивления.
supColor Цвет зоны поддержки — Цвет фона активной зоны поддержки.
supLine Цвет линии поддержки — Цвет границы и текста для зон и маркеров поддержки.
Получить полный код

Поиск по коду файла

indicator('High Volume Pivot Support & Resistance Zones [BigBeluga]', overlay = true, max_boxes_count = 500)

var string G_PIVOT = 'Pivot Settings'
resLen = input.int(40, title = 'Resistance Pivot Length', minval = 1, group = G_PIVOT, tooltip = 'The number of bars required before and after a high peak to confirm a structural resistance pivot.')
supLen = input.int(40, title = 'Support Pivot Length', minval = 1, group = G_PIVOT, tooltip = 'The number of bars required before and after a low trough to confirm a structural support pivot.')

var string G_VOL = 'Volume Validation'
volAvgLen = input.int(20, title = 'Volume MA Length', minval = 1, group = G_VOL, tooltip = 'The lookback period used to calculate the Simple Moving Average (SMA) of volume for baseline comparison.')
volMult = input.float(1.2, title = 'Volume Threshold Multiplier', minval = 0.1, group = G_VOL, tooltip = 'The multiplier applied to the volume SMA baseline. A pivot bar must exceed this total value to be validated.')

var string G_ZONE = 'Zone Settings'
atrLen      = 100
resColor    = input.color(color.new(#2196f3, 85), title = 'Resistance Zone Color', group = G_ZONE, tooltip = 'The background fill color applied to active resistance zones.')
resLine     = input.color(#2196f3, title = 'Resistance Line Color', group = G_ZONE, tooltip = 'The outline border color for resistance zones and its corresponding text markers.')
supColor    = input.color(color.new(#ffc13b, 85), title = 'Support Zone Color', group = G_ZONE, tooltip = 'The background fill color applied to active support zones.')
supLine     = input.color(#ffc13b, title = 'Support Line Color', group = G_ZONE, tooltip = 'The outline border color for support zones and its corresponding text markers.')

atr = ta.atr(200)

avgVol = ta.sma(volume, volAvgLen)
isHighVolume = volume > avgVol * volMult

volDelta = close >= open ? volume : -volume

pHi = ta.pivothigh(high, resLen, resLen)
pLo = ta.pivotlow(low, supLen, supLen)

validPivotHigh = not na(pHi) and isHighVolume[resLen]
validPivotLow = not na(pLo) and isHighVolume[supLen]

var box lastResBox = na
var box lastSupBox = na

var polyline resDeltaLine = na
var polyline supDeltaLine = na

var label resCvdLabel = na
var label supCvdLabel = na

var array<chart.point> resPoints = array.new<chart.point>()
var array<chart.point> supPoints = array.new<chart.point>()
var array<float> resDeltas = array.new<float>()
var array<float> supDeltas = array.new<float>()

var float cumResDelta = 0.0
var float cumSupDelta = 0.0

var bool resBroken = false
var bool supBroken = false

bool triggerResBreak = false
bool triggerSupBreak = false
bool triggerResRetest = false
bool triggerSupRetest = false
bool triggerFlippedResRetest = false
bool triggerFlippedSupRetest = false

normalizeDeltaToBox(float currentDelta, float minDelta, float maxDelta, float boxBottom, float boxTop) =>
    float rangeDelta = maxDelta - minDelta
    float rangeBox = boxTop - boxBottom
    rangeDelta == 0 ? boxBottom + rangeBox / 2 : boxBottom + (currentDelta - minDelta) / rangeDelta * rangeBox

formatVolume(float vol) =>
    float absVol = math.abs(vol)
    string sign = vol < 0 ? '-' : ''
    if absVol >= 1000000
        sign + str.tostring(absVol / 1000000, '0.0') + 'M'
    else if absVol >= 1000
        sign + str.tostring(absVol / 1000, '0.0') + 'K'
    else
        sign + str.tostring(absVol, '0')

if validPivotHigh
    resBroken := false
    float pivotBodyTop = math.max(open[resLen], close[resLen])
    float topPrice = pivotBodyTop + atr[resLen]
    float bottomPrice = pivotBodyTop

    if not na(lastResBox)
        box.set_right(lastResBox, bar_index)

    string volText = 'Vol: ' + formatVolume(-volume[resLen])
    lastResBox := box.new(left = bar_index - resLen, top = topPrice, right = bar_index, bottom = bottomPrice, bgcolor = resColor, border_color = resLine, border_style = line.style_solid, text = volText, text_size = size.small, text_color = resLine, text_valign = text.align_top, text_halign = text.align_left)

    if not na(resDeltaLine)
        polyline.delete(resDeltaLine)
    if not na(resCvdLabel)
        label.delete(resCvdLabel)

    cumResDelta := 0.0
    array.clear(resPoints)
    array.clear(resDeltas)

    for i = resLen to 0 by 1
        cumResDelta := cumResDelta + volDelta[i]
        array.push(resDeltas, cumResDelta)
        array.push(resPoints, chart.point.from_index(bar_index - i, bottomPrice))

    resDeltaLine := polyline.new(points = resPoints, line_color = chart.fg_color, line_width = 1, line_style = line.style_dotted)
    resCvdLabel := label.new(x = bar_index, y = bottomPrice, text = 'CVD: ' + formatVolume(cumResDelta), color = color.new(color.black, 100), textcolor = resLine, style = label.style_label_left, size = size.small)
    resCvdLabel
else
    if not na(lastResBox)
        box.set_right(lastResBox, bar_index)
        float rTop = box.get_top(lastResBox)
        float rBottom = box.get_bottom(lastResBox)

        cumResDelta := cumResDelta + volDelta
        array.push(resDeltas, cumResDelta)
        array.push(resPoints, chart.point.from_index(bar_index, rBottom))

        color activeResLineColor = close > rTop or resBroken ? supLine : resLine

        if array.size(resPoints) > 1
            float maxD = array.max(resDeltas)
            float minD = array.min(resDeltas)
            float finalScaledY = rBottom

            for i = 0 to array.size(resPoints) - 1 by 1
                float currentD = array.get(resDeltas, i)
                float scaledY = normalizeDeltaToBox(currentD, minD, maxD, rBottom, rTop)
                pointItem = array.get(resPoints, i)
                array.set(resPoints, i, chart.point.from_index(pointItem.index, scaledY))
                if i == array.size(resPoints) - 1
                    finalScaledY := scaledY
                    finalScaledY

            if not na(resDeltaLine)
                polyline.delete(resDeltaLine)
            resDeltaLine := polyline.new(points = resPoints, line_color = chart.fg_color, line_width = 1, line_style = line.style_dotted)

            if not na(resCvdLabel)
                label.delete(resCvdLabel)
            resCvdLabel := label.new(x = bar_index, y = finalScaledY, text = 'CVD: ' + formatVolume(cumResDelta), color = color.new(color.black, 100), textcolor = activeResLineColor, style = label.style_label_left, siz

Показано первые 50% кода (символов: 9833)

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
983,30₽ ≈ $12.02