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

indicator_rolling_candle_profile_with_buysell_signals_for_tradingview.pine

Похожие материалы по тегам

#4 solid trend (white).mq5MQL5 / MetaTrader 5 · 1 общих теговrachmad imam tarecha.mq4MQL4 / MetaTrader 4 · 1 общих тегов2 to 1 strategy with signals.pineTradingView · 1 общих теговindicator_arrows.mq5MQL5 / MetaTrader 5 · 1 общих теговcci'hma minmax levels aa mtf sv+tt 1.mq5MQL5 / MetaTrader 5 · 1 общих теговmultihedgeea_v1[1].3.temp.mq4MQL4 / MetaTrader 4 · 1 общих тегов
Вы автор или правообладатель?

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

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

О программе

Данный индикатор для TradingView отображает профиль свечей с сигналами покупки и продажи. Он рассчитывает давление цены на основе различных методов, включая чисто ценовой анализ, дельту объема или гибридный подход.

Индикатор строит коридор давления вокруг опорной линии (Anchor), которая может быть рассчитана с использованием различных скользящих средних или других методов. Цветовые полосы в этом коридоре визуализируют распределение покупательского и продавцовского давления.

Пользователь может настраивать различные параметры, такие как влияние усов свечей, ширина локализации цены и пороговые значения для активации сигналов. Индикатор также отображает метки BUY/SELL при соблюдении заданных условий давления и расположения цены относительно опорной линии.

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

НастройкаОписание
anchType Тип опорной серии цен, используемой для построения коридора давления (EMA, SMA, VWMA, VWAP, Donchian Mid).
anchorLen Период, используемый для расчета опорной линии, если ее расчет зависит от длины.
pressMode Метод расчета давления: чисто ценовое давление, дельта объема или гибридный подход.
tfMode Режим таймфрейма внутри бара: автоматический выбор меньшего таймфрейма или ручной выбор.
manTf Ручной выбор таймфрейма для анализа внутрисвечного давления, если выбран ручной режим.
pxWidth Ширина локализации цены. Меньшие значения создают более выраженные карманы давления, более высокие значения сглаживают градиент.
wickW Влияние отклонения, вызванного усами свечей, на поле направленного давления.
brightness Управляет видимостью градиента без изменения базового расчета давления.
buyCol Цвет, используемый для отображения полос покупательского давления и восходящей опорной линии.
sellCol Цвет, используемый для отображения полос продавцовского давления и нисходящей опорной линии.
anchOn Отображать ли опорную линию и ее полупрозрачное свечение.
sigOn Включить или отключить отображение сигналов BUY / SELL.
sigDom Минимальный дисбаланс направленного давления. Сигналы требуют, чтобы было видно минимальное количество окрашенных полос. Направленный дисбаланс измеряется относительно видимого профиля.
minBands Минимальное количество окрашенных градиентных полос, которое должно быть видимо, прежде чем может сработать сигнал BUY или SELL.
sigGap Минимальное количество баров между сигналами BUY или между сигналами SELL. Сигналы противоположного направления имеют независимый интервал и могут сработать немедленно.
txtSize Размер текста для меток BUY / SELL (Tiny, Small, Normal, Large, Huge).
txtCol Общий цвет текста для меток BUY / SELL.
buyLabCol Цвет фона для меток BUY.
sellLabCol Цвет фона для меток SELL.
labLookback Период для просмотра экстремумов, используемых для размещения меток.
labMaxGap Максимальное расстояние (в ATR) между меткой и свечой обнаружения, предотвращающее
Получить полный код

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

indicator("Rolling Candle Profile with Buy/Sell Signals", overlay=true, behind_chart=true, max_bars_back=250, calc_bars_count=2500, max_labels_count=500)

const string ttAnchor="Selects the reference price series used to construct the rolling pressure corridor."
const string ttAnchorLen="Lookback for the selected anchor when its calculation uses a length."
const string ttPress="Price Pressure isolates directional price displacement, follow-through and wick rejection without volume. Volume Delta estimates directional traded volume. Hybrid combines price response and volume. None are true bid/ask delta."
const string ttTfMode="Auto selects a smaller timeframe where available. Manual uses the chosen timeframe."
const string ttManual="Used in Manual mode. Chart uses the main chart timeframe; choose a lower timeframe to use intrabar pressure."
const string ttWidth="Lower values create more distinct pressure pockets. Higher values smooth the gradient."
const string ttWick="Contribution of upper- and lower-wick rejection to the directional pressure field."
const string ttBright="Controls visibility of the rolling gradient without changing the underlying pressure calculation."
const string ttBuyCol="Color for visible buying-pressure bands and a rising anchor."
const string ttSellCol="Color for visible selling-pressure bands and a falling anchor."
const string ttShowAnchor="Draw the anchor and its wider, 50%-transparent glow."
const string ttSignals="Display profile-aligned BUY and SELL labels when the existing signal rules are met."
const string ttDom="Minimum directional pressure imbalance. Signals require the selected Minimum colored bands. The directional imbalance is measured from the visible Rolling Profile."
const string ttBands="Requires at least this many of the 12 gradient bands to be visibly colored before a BUY or SELL signal can trigger. Lower the value for earlier signals."
const string ttGap="Minimum bars between BUY signals or between SELL signals. Opposite-direction signals have independent spacing and can trigger immediately."
const string ttTextSize="Shared BUY / SELL label text size."
const string ttTextCol="Shared BUY / SELL label text color."
const string ttBuyLabel="Background color of BUY labels."
const string ttSellLabel="Background color of SELL labels."
const string ttExtremes="Place a signal just beyond the recent high/low, but always on its actual detection bar."
const string ttMaxGap="Caps how far labels can sit above/below the detection candle, preventing floating labels when the recent extreme occurred several bars ago."

gA="Anchor"
gP="Pressure engine"
gG="Gradient"
gS="Signals"

anchType=input.string("EMA", "Anchor", options=["EMA", "SMA", "VWMA", "VWAP", "Donchian Mid"], group=gA, inline="anchor", tooltip=ttAnchor)
anchorLen=input.int(21, "Length", minval=5, maxval=200, group=gA, inline="anchor", tooltip=ttAnchorLen)

pressMode=input.string("Price Pressure", "Pressure input", options=["Price Pressure", "Volume Delta", "Hybrid"], group=gP, inline="pressMode", tooltip=ttPress)
tfMode=input.string("Manual", "Intrabar timeframe", options=["Auto", "Manual"], group=gP, inline="ltf", tooltip=ttTfMode)
manTf=input.timeframe("", "", group=gP, inline="ltf", active=tfMode=="Manual", tooltip=ttManual)
pxWidth=input.float(0.01, "Price-localization width", minval=0.01, maxval=2.0, step=0.05, group=gP, inline="pxWidth", tooltip=ttWidth)
wickW=input.float(0.85, "Wick rejection influence", minval=0.0, maxval=2.5, step=0.05, group=gP, inline="wickW", tooltip=ttWick)

brightness=input.float(3.0, "Brightness", minval=0.5, maxval=3.0, step=0.1, group=gG, inline="brightness", tooltip=ttBright)
buyCol=input.color(#00EFB4, "Buying pressure", group=gG, inline="pressCol", tooltip=ttBuyCol)
sellCol=input.color(#FF3D6E, "Selling pressure", group=gG, inline="pressCol", tooltip=ttSellCol)
anchOn=input.bool(true, "Show anchor", group=gG, inline="anchOn", tooltip=ttShowAnchor)

sigOn=input.bool(true, "BUY / SELL signals", group=gS, inline="sigOn", tooltip=ttSignals)
sigDom=input.float(0.25, "Pressure dominance threshold", minval=0.05, maxval=0.95, step=0.05, group=gS, inline="sigDom", active=sigOn, tooltip=ttDom)
minBands=input.int(7, "Minimum colored bands", minval=1, maxval=12, group=gS, inline="minBands", active=sigOn, tooltip=ttBands)
sigGap=input.int(6, "Minimum signal spacing", minval=1, maxval=40, group=gS, inline="sigGap", active=sigOn, tooltip=ttGap)
txtSize=input.string("Small", "Text size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group=gS, inline="sigTxt", active=sigOn, tooltip=ttTextSize)
txtCol=input.color(color.white, "Text color", group=gS, inline="sigTxt", active=sigOn, tooltip=ttTextCol)
buyLabCol=input.color(#22c55e, "BUY label", group=gS, inline="sigCol", active=sigOn, tooltip=ttBuyLabel)
sellLabCol=input.color(#f23645, "SELL label", group=gS, inline="sigCol", active=sigOn, tooltip=ttSellLabel)
labLookback=input.int(10, "Label extremes lookback", minval=1, maxval=30, group=gS, inline="labLookback", active=sigOn, tooltip=ttExtremes)
labMaxGap=input.float(1.0, "Max label distance (ATR)", minval=0.15, maxval=3.0, step=0.05, group=gS, inline="labMaxGap", active=sigOn, tooltip=ttMaxGap)

clamp(float x, float lo, float hi) => math.max(lo, math.min(hi, x))
kernel(float here, float center, float invW) =>
    q = 1.0 - math.abs(here - center) * invW
    q <= 0.0 ? 0.0 : q * q * (3.0 - 2.0 * q)
mixCol(color a, color b, float amount) =>
    t = clamp(amount, 0.0, 1.0)
    color.rgb(int(math.round(color.r(a) * (1.0 - t) + color.r(b) * t)), int(math.round(color.g(a) * (1.0 - t) + 
     color.g(b) * t)), int(math.round(color.b(a) * (1.0 - t) + color.b(b) * t)))

baseEma = ta.ema(close, anchorLen)
anchor = switch anchType
    "SMA" => ta.sma(close, anchorLen)
    "VWMA" =>
        v = ta.vwma(close, anchorLen)
        na(v) ? baseEma : v
    "VWAP" =>
        v = ta.vwap(hlc3)
        na(v) ? baseEma : v
    "Donchian Mid" => (ta.highest(high, anchorLen)[1] + ta.lowest(low, anchorLen)[1]) * 0.5
    => baseEma

chartSec = timeframe.in_seconds()
propSec = int(math.max(60.0, math.floor(chartSec / 5.0)))
autoTf = timeframe.from_seconds(propSec)
ltf = tfMode == "Auto" ? autoTf : manTf
ltfSec = timeframe.in_seconds(ltf)
useLtf = ltfSec < chartSec
reqBars = int(math.min(100000.0, math.ceil((2500.0 + 250.0) * chartSec / math.max(ltfSec, 1.0))))
buyNow = 0.0
sellNow = 0.0
buyPxSum = 0.0
sellPxSum = 0.0
lowRej = 0.0
highRej = 0.0
lowPxSum = 0.0
highPxSum = 0.0
stallNow = 0.0
stallPxSum = 0.0
totalNow = 0.0
isPrice = pressMode == "Price Pressure"
isHybrid = pressMode == "Hybrid"
hasMicro = false

if useLtf
    [io, ih, il, ic, iv] = request.security_lower_tf(syminfo.tickerid, ltf, [open, high, low, close, volume], 
     ignore_invalid_timeframe = true, calc_bars_count = reqBars)
    nMicro = ic.size()
    microLimit = math.min(nMicro, 90)
    if microLimit > 0
        hasMicro := true
        prevResp = 0.0
        for i = nMicro - microLimit to nMicro - 1
            o = io.get(i)
            h = ih.get(i)
            l = il.get(i)
            c = ic.get(i)
            rawV = nz(iv.get(i)) > 0.0 ? iv.get(i) : 1.0
            r = math.max(h - l, syminfo.mintick)
            prevC = i > 0 ? ic.get(i - 1) : nz(close[1], o)
            directional = clamp((c - o) / r, -1.0, 1.0)
            impulse = math.abs(directional)
            travel = clamp((c - prevC) / r, -1.5, 1.5)
            closeLoc = clamp((2.0 * c - h - l) / r, -1.0, 1.0)
            response = clamp(0.55 * travel + 0.25 * directional + 0.20 * closeLoc, -1.5, 1.5)
            force = math.abs(response)
            continuation = response * prevResp > 0.0 ? 1.45 : response * prevResp < 0.0 ? 0.55 : 1.0
            cp = (h + l + c) / 3.0
            lowW = math.max(0.0, math.min(o, c) - l) / r
            highW = math.max(0.0, h - math.max(o, c)) / r
            v = isHybrid ? rawV * (0.65 + force * 0.70) : rawV
            flowDir = isHybrid ? clamp(0.45 * directional + 0.55 * response, -1.0, 1.0) : directional
            buyPart = isPrice ? math.max(response, 0.0) * (1.0 + force * 1.25) * continuation * 2.0 : v * (1.0 + flowDir) * 0.5
            sellPart = isPrice ? math.max(-response, 0.0) * (1.0 + force * 1.25) * continuation * 2.0 : v * (1.0 - flowDir) * 0.5
            rejBuy = isPrice ? lowW * (0.35 + 1.20 * math.max(response, 0.0)) : v * lowW
            rejSell = isPrice ? highW * (0.35 + 1.20 * math.max(-response, 0.0)) : v * highW
            stalled = isPrice ? (1.0 - clamp(force, 0.0, 1.0)) * 0.20 : v * (1.0 - impulse)

            bPx = isPrice ? c * 0.70 + h * 0.30 : isHybrid ? (cp * 0.75 + h * 0.25) : cp
            sPx = isPrice ? c * 0.70 + l * 0.30 : isHybrid ? (cp * 0.75 + l * 0.25) : cp
            buyNow += buyPart
            sellNow += sellPart
            buyPxSum += buyPart * bPx
            sellPxSum += sellPart * sPx
            lowRej += rejBuy
            highRej += rejSell
            lowPxSum += rejBuy * (l + math.min(o, c)) * 0.5
            highPxSum += rejSell * (h + math.max(o, c)) * 0.5
            stallNow += stalled
            stallPxSum += stalled * cp
            totalNow += isPrice ? (buyPart + sellPart + rejBuy + rejSell + stalled) : v
            prevResp := response
if not hasMicro
    r = math.max(high - low, syminfo.mintick)
    directional = clamp((close - open) / r, -1.0, 1.0)
    impulse = math.abs(directional)
    travel = clamp((close - nz(close[1], open)) / r, -1.5, 1.5)
    closeLoc = clamp((2.0 * close - high - low) / r, -1.0, 1.0)
    response = clamp(0.55 * travel + 0.25 * directional + 0.20 * closeLoc, -1.5, 1.5)
    force = math.abs(response)
    priorTravel = nz(close[1] - close[2])
    continuation = priorTravel * response > 0.0 ? 1.45 : priorTravel * response < 0.0 ? 0.55 : 1.0
    rawV = nz(volume) > 0.0 ? volume : 1.0
    v = isHybrid ? rawV * (0.65 + force * 0.70) : rawV
    flowDir = isHybrid ? clamp(0.45 * directional + 0.55 * response, -1.0, 1.0) : directional
    buyNow := isPrice ? math.max(response, 0.0) * (1.0 + force * 1.25) * continuation * 2.0 : v * (1.0 + flowDir) * 0.5
    sellNow := isPrice ? math.max(-response, 0.0) * (1.0 + force * 1.25) * continuation * 2.0 : v * (1.0 - flowDir) * 0.5
    lowW = math.max(0.0, math.min(open, close) - low) / r
    highW = math.max(0.0, high - math.max(open, close)) / r
    lowRej := isPrice ? lowW * (0.35 + 1.20 * math.max(response, 0.0)) : v * lowW
    highRej := isPrice ? highW * (0.35 + 1.20 * math.max(-response, 0.0)) : v * highW
    stallNow := isPrice ? (1.0 - clamp(force, 0.

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

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

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

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

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

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

Стоимость полного кода
1 691,80₽ ≈ $20.68