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

Liquidity Sweep Reversal & Targets

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

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

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

О программе

Индикатор для TradingView на Pine Script v6, отображающий на графике зоны ликвидности и планы сделок. Он рассчитывает свинговые уровни (BSL и SSL), отслеживает их пробои и формирует визуальные подсказки о возможных разворотах. В основе лежит оценка покупательской и продавцовской абсорбции, а также сравнение нескольких встроенных профилей фильтрации. Индикатор не является торговым советником и не выполняет сделки; все расчёты и отображение происходят на стороне TradingView.

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

НастройкаОписание
pivotLen Количество подтверждённых баров слева и справа для определения свинговых уровней ликвидности.
maxPoolsSide Максимальное количество активных зон ликвидности с каждой стороны, отображаемых одновременно.
zoneWidthAtr Толщина зоны защиты ликвидности в единицах ATR.
filterPreset Режим фильтрации сигналов абсорбции: автоматический подбор, сбалансированный, консервативный, агрессивный и другие профили.
customMinAbsorb Минимальный порог абсорбции в процентах, используемый при выборе пользовательского режима фильтрации.
targetMode Способ расчёта целей: фиксированная лестница R или привязка к ближайшей противоположной зоне ликвидности.
slBufferAtr Дополнительный буфер в единицах ATR за экстремумом свечи для уровня стоп-лосса.
useBeRatchet Переводит стоп-лосс в безубыток после достижения первой цели.
showPastPlans Сохраняет на графике до пяти последних торговых планов выбранного профиля.
showSkipped Отображает метки для пробоев ликвидности, которые были отфильтрованы и пропущены.
showDash Показывает или скрывает сводную панель с текущими параметрами и статистикой.
dashSizeInput Размер текста в сводной панели индикатора.
bullCol Цвет для бычьих зон ликвидности, сигналов на покупку и зон целей.
bearCol Цвет для медвежьих зон ликвидности, сигналов на продажу и зон риска.
Получить полный код

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

indicator(
     title            = "Liquidity Sweep Reversal & Targets",
     shorttitle       = "LSRT",
     overlay          = true,
     max_lines_count  = 500,
     max_labels_count = 500,
     max_boxes_count  = 300
)

max_bars_back(time, 64)

enum FilterMode
    AUTO_OPTIMIZE = "Auto-Optimize (Best Chart Win Rate)"
    BALANCED      = "Balanced (55% Absorb)"
    CONSERVATIVE  = "Conservative (65% Absorb)"
    AGGRESSIVE    = "Aggressive (45% Absorb)"
    TREND_ALIGNED = "Trend-Aligned (EMA 50 + 52% Absorb)"
    VOL_CLIMAX    = "Volume Climax (62% Absorb + 1.25x Vol)"
    WIDE_DEFENSE  = "Wide-Stop Defense (60% Absorb + 1.6x SL)"
    CUSTOM        = "Custom Threshold"

enum TargetMode
    HYBRID      = "R Ladder + Opposing Pool Magnet"
    R_MULTIPLES = "Fixed R Ladder (1R / 2R / 3R)"

enum DashSize
    TINY   = "Tiny"
    SMALL  = "Small"
    NORMAL = "Normal"
    LARGE  = "Large"

string GRP_POOL = "1. Liquidity Defense Zones"
string GRP_FILT = "2. Sweep Absorption & Auto-Optimizer"
string GRP_PLAN = "3. Entry, Stop Loss & TP1–TP3 Targets"
string GRP_VIS  = "4. Visuals & Dashboard"

int        pivotLen        = input.int(10, "Swing Liquidity Lookback", minval = 3, maxval = 50, group = GRP_POOL, tooltip = "Confirmed left/right bars used to detect Buy-Side (BSL) and Sell-Side (SSL) swing liquidity pools. Pools rest in advance so sweeps trigger on bar close without right-pivot delay.")
int        maxPoolsSide    = input.int(2, "Active Pools Shown Per Side", minval = 1, maxval = 5, group = GRP_POOL, tooltip = "Maximum number of unmitigated Buy-Side (above price) and Sell-Side (below price) liquidity defense zones displayed at once.")
float      zoneWidthAtr    = input.float(0.35, "Defense Zone Thickness (ATR)", minval = 0.10, maxval = 1.20, step = 0.05, group = GRP_POOL, tooltip = "Volatility-scaled thickness of each BSL and SSL liquidity defense zone in ATR(14) units.")

FilterMode filterPreset    = input.enum(FilterMode.AUTO_OPTIMIZE, "Absorption Filter Mode", group = GRP_FILT, tooltip = "Auto-Optimize runs all 6 built-in strategy profiles in parallel across the current asset and timeframe, then selects and renders the exact profile with the highest closed-bar TP1+ Win Rate.")
float      customMinAbsorb = input.float(55.0, "Custom Min Absorption (%)", minval = 25.0, maxval = 90.0, step = 5.0, group = GRP_FILT, active = filterPreset == FilterMode.CUSTOM, tooltip = "Minimum Buyer/Seller Absorption score (0–100%) required when Absorption Filter Mode is set to Custom Threshold.")

TargetMode targetMode      = input.enum(TargetMode.HYBRID, "Target Projection Mode", group = GRP_PLAN, tooltip = "Fixed R Ladder projects TP1/TP2/TP3 at 1.0R, 2.0R, and 3.0R. R Ladder + Opposing Pool Magnet snaps TP3 to the nearest unbroken opposing liquidity pool when it offers a clean structural target.")
float      slBufferAtr     = input.float(0.20, "Stop Loss Buffer Beyond Wick (ATR)", minval = 0.05, maxval = 1.00, step = 0.05, group = GRP_PLAN, tooltip = "Base ATR(14) breathing room placed beyond the sweep wick extreme for the Stop Loss level.")
bool       useBeRatchet    = input.bool(true, "Move Stop to Breakeven After TP1", group = GRP_PLAN, tooltip = "When enabled, once TP1 is reached on a confirmed bar, the active Stop Loss ratchets to the Entry price (Breakeven) for remaining targets.")

bool       showPastPlans   = input.bool(false, "Keep Historical Trade Plans (Last 5)", group = GRP_VIS, tooltip = "Off by default so only the current/latest trade plan stays on price. Enable to keep the last 5 trade plans of the active profile visible on the chart.")
bool       showSkipped     = input.bool(false, "Show Filtered (SKIP) Sweeps", group = GRP_VIS, tooltip = "Displays small muted markers when a liquidity sweep occurs but fails the active profile's filter.")
bool       showDash        = input.bool(true, "Show Summary Dashboard", group = GRP_VIS, tooltip = "Displays the live Liquidity Sweep, Absorption %, Auto-Optimizer Winner, Trade Plan, and Win/Loss performance table in the top-right corner.")
DashSize   dashSizeInput   = input.enum(DashSize.SMALL, "Table Size", group = GRP_VIS, active = showDash, tooltip = "Scales text size inside the summary dashboard.")
color      bullCol         = input.color(#00E6A8, "Bullish Reversal & Reward Color", group = GRP_VIS, tooltip = "Accent color for Sell-Side Liquidity (SSL) defense zones, BUY callouts, and Take-Profit zones.")
color      bearCol         = input.color(#FF3B69, "Bearish Reversal & Risk Color", group = GRP_VIS, tooltip = "Accent color for Buy-Side Liquidity (BSL) defense zones, SELL callouts, and Stop-Loss zones.")

type LiqPool
    int   side       // 1 = BSL (Swing High Resistance), -1 = SSL (Swing Low Support)
    float level      // Exact swing pivot price
    float outerBound // Outer defense boundary
    float innerBound // Inner boundary for visual zone box
    int   pivotTime  // Opening timestamp captured when the pivot is confirmed
    float defPct     // Buyer/Seller defense absorption % (0-100)
    box   zoneBox
    line  lvlLine
    label zoneLbl

method clearPoolDrawings(LiqPool this) =>
    if not na(this.zoneBox)
        box.delete(this.zoneBox)
        this.zoneBox := na
    if not na(this.lvlLine)
        line.delete(this.lvlLine)
        this.lvlLine := na
    if not na(this.zoneLbl)
        label.delete(this.zoneLbl)
        this.zoneLbl := na

type SavedPlan
    int   profId
    int   dir
    int   entryBar
    float entry
    float initSl
    float activeSl
    float risk
    float tp1
    float tp2
    float tp3
    float tp1R
    float tp2R
    float tp3R
    bool  tp3IsMag
    float absorbPct
    bool  tp1Hit
    bool  tp2Hit
    bool  tp3Hit
    bool  slHit
    bool  beHit
    int   status // 0 = ACTIVE, 1 = TP3 FULL WIN, 2 = PARTIAL WIN (TP1+), -1 = LOSS (SL), 3 = EXPIRED/FLIP
    int   endTime
    int   swLeftTime
    float swTop
    float swBot
    int   entryTime
    float signalY    // Stored price anchor; avoids abovebar/belowbar history lookups

type ProfileEngine
    int    id
    string nameTag
    float  minAbsorb
    float  maxSweep
    float  slScale
    float  minRiskAtr
    bool   requireTrend
    float  minRelAct
    int    totalTrades
    int    winTrades
    int    lossTrades
    int    tp1Count
    int    tp2Count
    int    tp3Count
    float  cumNetR
    int    lastSigDir
    float  lastSigAbsorb
    string lastSigText
    int    activePlanIdx // Index in global allPlans array (-1 if none)
    bool   barBullTake
    bool   barBearTake
    bool   barBullSkip
    bool   barBearSkip
    bool   barTp1Evt
    bool   barTp2Evt
    bool   barTp3Evt
    bool   barSlEvt

f_clamp(float val, float lo, float hi) =>
    math.min(math.max(val, lo), hi)

float rawAtr      = ta.atr(14)
float safeAtr     = nz(rawAtr, math.max(high - low, syminfo.mintick * 10.0))
float barSpan     = math.max(high - low, syminfo.mintick)
float emaTrend    = ta.ema(close, 50)
bool  bullTrendOk = close >= nz(emaTrend, close)
bool  bearTrendOk = close <= nz(emaTrend, close)

float volSma      = ta.sma(volume, 20)
bool  hasRealVol  = not na(volume) and volume > 0 and not na(volSma) and volSma > 0
float relActivity = hasRealVol ? (volume / volSma) : (barSpan / math.max(safeAtr, syminfo.mintick))
float actNorm     = f_clamp(relActivity / 2.0, 0.0, 1.0)

float bullCloseShare  = f_clamp((close - low) / barSpan, 0.0, 1.0)
float bearCloseShare  = f_clamp((high - close) / barSpan, 0.0, 1.0)
float rawBarDelta     = ((2.0 * bullCloseShare) - 1.0) * f_clamp(relActivity, 0.3, 2.5)
float netDeltaPct     = f_clamp(ta.ema(rawBarDelta, 5) * 60.0, -100.0, 100.0)

float bullBodyBonus   = close >= open ? 1.0 : 0.65
float bearBodyBonus   = close <= open ? 1.0 : 0.65
float buyerAbsorbVal  = math.round(f_clamp((0.50 * bullCloseShare + 0.35 * actNorm + 0.15 * bullBodyBonus) * 100.0, 0.0, 100.0), 1)
float sellerAbsorbVal = math.round(f_clamp((0.50 * bearCloseShare + 0.35 * actNorm + 0.15 * bearBodyBonus) * 100.0, 0.0, 100.0), 1)

var array<LiqPool>       bslPools   = array.new<LiqPool>()
var array<LiqPool>       sslPools   = array.new<LiqPool>()
var array<ProfileEngine> engines    = array.new<ProfileEngine>()
var array<SavedPlan>     allPlans   = array.new<SavedPlan>()
var array<box>           drawnBoxes = array.new<box>()
var array<line>          drawnLines = array.new<line>()
var array<label>         drawnLbls  = array.new<label>()

if barstate.isfirst

    array.push(engines, ProfileEngine.new(0, "Balanced (55% Absorb)",       55.0, 1.50, 1.00, 0.35, false, 0.00, 0, 0, 0, 0, 0, 0, 0.0, 0, 0.0, "NONE", -1, false, false, false, false, false, false, false, false))
    array.push(engines, ProfileEngine.new(1, "Conservative (65% Absorb)",   65.0, 1.25, 1.15, 0.35, false, 0.00, 0, 0, 0, 0, 0, 0, 0.0, 0, 0.0, "NONE", -1, false, false, false, false, false, false, false, false))
    array.push(engines, ProfileEngine.new(2, "Aggressive (45% Absorb)",     45.0, 2.00, 0.85, 0.30, false, 0.00, 0, 0, 0, 0, 0, 0, 0.0, 0, 0.0, "NONE", -1, false, false, false, false, false, false, false, false))
    array.push(engines, ProfileEngine.new(3, "Trend-Aligned (EMA 50)",      52.0, 1.60, 0.90, 0.30, true,  0.00, 0, 0, 0, 0, 0, 0, 0.0, 0, 0.0, "NONE", -1, false, false, false, false, false, false, false, false))
    array.push(engines, ProfileEngine.new(4, "Volume Climax (62% + RVOL)",  62.0, 1.40, 0.80, 0.28, false, 1.25, 0, 0, 0, 0, 0, 0, 0.0, 0, 0.0, "NONE", -1, false, false, false, false, false, false, false, false))
    array.push(engines, ProfileEngine.new(5, "Wide-Stop Defense (1.6x SL)", 60.0, 1.50, 1.60, 0.45, false, 0.00, 0, 0, 0, 0, 0, 0, 0.0, 0, 0.0, "NONE", -1, false, false, false, false, false, false, false, false))
    array.push(engines, ProfileEngine.new(6, "Custom Threshold",            customMinAbsorb, 1.60, 1.00, 0.35, false, 0.00, 0, 0, 0, 0, 0, 0, 0.0, 0, 0.0, "NONE", -1, false, false, false, false, false, false, false, false))

if array.size(engines) == 7
    ProfileEngine custEng = array.get(engines, 6)
    custEng.minAbsorb := customMinAbsorb

float ph = ta.pivothigh(high, pivotLen, pivotLen)
float pl = ta.pivotlow(low, pivotLen, pivotLen)
float phDefScore = sellerAbsorbVal[pivotLen]
float plDefScore = buyerAbsorbVal[pivotLen]
int   pivotTime = time[pivotLen]
int   sweepWindowTime = nz(time[12], time)

float fiveBarMoveAtr = (close - nz(close[5], close)) / math.max(safeAtr, syminfo.mintick)
bool  bearCrashGuard = fiveBarMoveAtr < -3.6 and close < open
bool  bullCrashGuard = fiveBarMoveAtr >  3.6 and close > open

if barstate.isconfirmed and array.size(engines) == 7

    for eIdx = 0 to 6
        ProfileEngine eng = array.get(engines, eIdx)
        eng.barBullTake := false
        eng.barBearTake := false
        eng.barBullSkip := false
        eng.barBearSkip := false
        eng.barTp1Evt   := false
        eng.barTp2Evt   := false
        eng.barTp3Evt   := false
        eng.barSlEvt    := false

        if eng.activePlanIdx >= 0 and eng.activePlanIdx < array.size(allPlans)
            SavedPlan cp = array.get(allPlans, eng.activePlanIdx)
            if cp.status == 0 and bar_index > cp.entryBar
                if cp.dir == 1
                    if low <= cp.activeSl
                        if cp.tp1Hit
                            cp.beHit       := true
                            cp.status      := 2
                            cp.endTime     := time
                            eng.totalTrades += 1
                            eng.winTrades   += 1
                            float bankedR  = cp.tp2Hit ? ((cp.tp1R + cp.tp2R) * 0.5) : (cp.tp1R * 0.5)
                            eng.cumNetR    += bankedR
                        else
                            cp.slHit       := true
                            cp.status      := -1
                            cp.endTime     := time
                            eng.totalTrades += 1
                            eng.lossTrades  += 1
                            eng.cumNetR    -= 1.0
                            eng.barSlEvt   := true
                    else
                        if not cp.tp1Hit and high >= cp.tp1
                            cp.tp1Hit     := true
                            eng.tp1Count  += 1
                            eng.barTp1Evt := true
                            if useBeRatchet
                                cp.activeSl := cp.entry
                        if not cp.tp2Hit and high >= cp.tp2
                            cp.tp2Hit     := true
                            eng.tp2Count  += 1
                            eng.barTp2Evt := true
                        if not cp.tp3Hit and high >= cp.tp3
                            cp.tp3Hit       := true
                            eng.tp3Count    += 1
                            eng.barTp3Evt   := true
                            cp.status       := 1
                            cp.endTime      := time
                            eng.totalTrades += 1
                            eng.winTrades   += 1
                            eng.cumNetR     += cp.tp3R
                        else if (bar_index - cp.entryBar) >= 60
                            cp.status       := cp.tp1Hit ? 2 : 3
                            cp.endTime      := time
                            eng.totalTrades += 1
                            if cp.tp1Hit
                                eng.winTrades += 1
                                eng.cumNetR   += cp.tp1R
                            else
                                float expR = (close - cp.entry) / math.max(cp.risk, syminfo.mintick)
                                if expR >= 0.0
                                    eng.winTrades  += 1
                                else
                                    eng.lossTrades += 1
                                eng.cumNetR += expR
                else if cp.dir == -1
                    if high >= cp.activeSl
                        if cp.tp1Hit
                            cp.beHit       := true
                            cp.status      := 2
                            cp.endTime     := time
                            eng.totalTrades += 1
                            eng.winTrades   += 1
                            float bankedR  = cp.tp2Hit ? ((cp.tp1R + cp.tp2R) * 0.5) : (cp.tp1R * 0.5)
                            eng.cumNetR    += bankedR
                        else
                            cp.slHit       := true
                            cp.status      := -1
                            cp.endTime     := time
                            eng.totalTrades += 1
                            eng.lossTrades  += 1
                            eng.cumNetR    -= 1.0
                            eng.barSlEvt   := true
                    else
                        if not cp.tp1Hit and low <= cp.tp1
                            cp.tp1Hit     := true
                            eng.tp1Count  += 1
                            eng.barTp1Evt := true
                            if useBeRatchet
                                cp.activeSl := cp.entry
                        if not cp.tp2Hit and low <= cp.tp2
                            cp.tp2Hit     := true
                            eng.tp2Count  += 1
                            eng.barTp2Evt := true
                        if not cp.tp3Hit and low <= cp.tp3
                            cp.tp3Hit       := true
                            eng.tp3Count    += 1
                            eng.barTp3Evt   := true
                            cp.status       := 1
                            cp.endTime      := time
                            eng.totalTrades += 1
                            eng.winTrades   += 1
                            eng.cumNetR     += cp.tp3R
                        else if (bar_index - cp.entryBar) >= 60
                            cp.status       := cp.tp1Hit ? 2 : 3
                            cp.endTime      := time
                            eng.totalTrades += 1
                            if cp.tp1Hit
                                eng.winTrades += 1
                                eng.cumNetR   += cp.tp1R
                            else
                                float expR = (cp.entry - close) / math.max(cp.risk, syminfo.mintick)
                                if expR >= 0.0
                                    eng.winTrades  += 1
                                else
                                    eng.lossTrades += 1
                                eng.cumNetR += expR

    bool  bullCand          = false
    float sweptSslLvl       = na
    float sweptSslOuter     = na
    int   sweptSslTime      = time
    float bullSweepDepthAtr = 0.0

    if array.size(sslPools) > 0
        for i = array.size(sslPools) - 1 to 0
            LiqPool p = array.get(sslPools, i)
            if close < p.outerBound or low < (p.level - 2.00 * safeAtr)
                p.clearPoolDrawings()
                array.remove(sslPools, i)
            else if low < p.level and close >= p.level
                bullCand := true
                if na(sweptSslLvl) or p.level < sweptSslLvl
                    sweptSslLvl       := p.level
                    sweptSslOuter     := p.outerBound
                    sweptSslTime      := p.pivotTime
                    bullSweepDepthAtr := (p.level - low) / math.max(safeAtr, syminfo.mintick)
                p.clearPoolDrawings()
                array.remove(sslPools, i)

    bool  bearCand          = false
    float sweptBslLvl       = na
    float sweptBslOuter     = na
    int   sweptBslTime      = time
    float bearSweepDepthAtr = 0.0

    if array.size(bslPools) > 0
        for i = array.size(bslPools) - 1 to 0
            LiqPool p = array.get(bslPools, i)
            if close > p.outerBound or high > (p.level + 2.00 * safeAtr)
                p.clearPoolDrawings()
                array.remove(bslPools, i)
            else if high > p.level and close <= p.level
                bearCand := true
                if na(sweptBslLvl) or p.level > sweptBslLvl
                    sweptBslLvl       := p.level
                    sweptBslOuter     := p.outerBound
                    sweptBslTime      := p.pivotTime
                    bearSweepDepthAtr := (high - p.level) / math.max(safeAtr, syminfo.mintick)
                p.clearPoolDrawings()
                array.remove(bslPools, i)

    if bullCand and bearCand
        bullCand := false
        bearCand := false

    int pBar = bar_index - pivotLen
    if not na(ph) and pBar >= 0
        float zThick = safeAtr * zoneWidthAtr
        float outerH = ph + zThick * 0.65
        float innerH = ph - zThick * 0.35
        bool  intact = true
        for k = 0 to pivotLen - 1
            if close[k] > outerH
                intact := false
        if intact
            LiqPool newBsl = LiqPool.new(1, ph, outerH, innerH, pivotTime, nz(phDefScore, 55.0), na, na, na)
            array.push(bslPools, newBsl)
            while array.size(bslPools) > 8
                LiqPool oldP = array.shift(bslPools)
                oldP.clearPoolDrawings()

    if not na(pl) and pBar >= 0
        float zThick = safeAtr * zoneWidthAtr
        float outerL = pl - zThick * 0.65
        float innerL = pl + zThick * 0.35
        bool  intact = true
        for k = 0 to pivotLen - 1
            if close[k] < outerL
                intact := false
        if intact
            LiqPool newSsl = LiqPool.new(-1, pl, outerL, innerL, pivotTime, nz(plDefScore, 55.0), na, na, na)
            array.push(sslPools, newSsl)
            while array.size(sslPools) > 8
                LiqPool oldP = array.shift(sslPools)
                oldP.clearPoolDrawings()

    if bullCand or bearCand
        for eIdx = 0 to 6
            ProfileEngine eng = array.get(engines, eIdx)
            bool trendPassBull = not eng.requireTrend or bullTrendOk
            bool trendPassBear = not eng.requireTrend or bearTrendOk
            bool actPass       = relActivity >= eng.minRelAct

            if bullCand
                if bullSweepDepthAtr <= eng.maxSweep and buyerAbsorbVal >= eng.minAbsorb and not bearCrashGuard and trendPassBull and actPass
                    eng.barBullTake   := true
                    eng.lastSigDir    := 1
                    eng.lastSigAbsorb := buyerAbsorbVal
                    eng.lastSigText   := "BUY (SSL · " + str.tostring(buyerAbsorbVal, "#") + "%)"
                else
                    eng.barBullSkip   := true
                    eng.lastSigText   := "SKIP (SSL · " + str.tostring(buyerAbsorbVal, "#") + "%)"

            if bearCand
                if bearSweepDepthAtr <= eng.maxSweep and sellerAbsorbVal >= eng.minAbsorb and not bullCrashGuard and trendPassBear and actPass
                    eng.barBearTake   := true
                    eng.lastSigDir    := -1
                    eng.lastSigAbsorb := sellerAbsorbVal
                    eng.lastSigText   := "SELL (BSL · " + str.tostring(sellerAbsorbVal, "#") + "%)"
                else
                    eng.barBearSkip   := true
                    eng.lastSigText   := "SKIP (BSL · " + str.tostring(sellerAbsorbVal, "#") + "%)"

            if eng.barBullTake or eng.barBearTake

                if eng.activePlanIdx >= 0 and eng.activePlanIdx < array.size(allPlans)
                    SavedPlan prevP = array.get(allPlans, eng.activePlanIdx)
                    if prevP.status == 0
                        prevP.status    := prevP.tp1Hit ? 2 : 3
                        prevP.endTime   := time
                        eng.totalTrades += 1
                        if prevP.tp1Hit
                            eng.winTrades += 1
                            eng.cumNetR   += prevP.tp1R
                        else
                            float flipR = prevP.dir == 1 ? (close - prevP.entry) / math.max(prevP.risk, syminfo.mintick) : (prevP.entry - close) / math.max(prevP.risk, syminfo.mintick)
                            if flipR >= 0.0
                                eng.winTrades  += 1
                            else
                                eng.lossTrades += 1
                            eng.cumNetR += flipR

                int   sDir   = eng.barBullTake ? 1 : -1
                float entryP = close
                float effSlB = slBufferAtr * eng.slScale
                float rawSl  = sDir == 1 ? (math.min(low, nz(sweptSslOuter, low)) - effSlB * safeAtr) : (math.max(high, nz(sweptBslOuter, high)) + effSlB * safeAtr)
                float clampedRisk = f_clamp(math.abs(entryP - rawSl), safeAtr * eng.minRiskAtr, safeAtr * 3.0)
                float finalSl = sDir == 1 ? (entryP - clampedRisk) : (entryP + clampedRisk)

                float tp1P = sDir == 1 ? (entryP + 1.0 * clampedRisk) : (entryP - 1.0 * clampedRisk)
                float tp2P = sDir == 1 ? (entryP + 2.0 * clampedRisk) : (entryP - 2.0 * clampedRisk)
                float tp3P = sDir == 1 ? (entryP + 3.0 * clampedRisk) : (entryP - 3.0 * clampedRisk)
                float tp3RVal = 3.0
                bool  isMag   = false

                if targetMode == TargetMode.HYBRID
                    if sDir == 1 and array.size(bslPools) > 0
                        float bestMag = na
                        for i = 0 to array.size(bslPools) - 1
                            LiqPool opp = array.get(bslPools, i)
                            float distR = (opp.level - entryP) / clampedRisk
                            if distR >= 2.2 and distR <= 4.5
                                if na(bestMag) or opp.level < bestMag
                                    bestMag := opp.level
                        if not na(bestMag)
                            tp3P    := bestMag
                            tp3RVal := math.round((bestMag - entryP) / clampedRisk, 1)
                            isMag   := true
                    else if sDir == -1 and array.size(sslPools) > 0
                        float bestMag = na
                        for i = 0 to array.size(sslPools) - 1
                            LiqPool opp = array.get(sslPools, i)
                            float distR = (entryP - opp.level) / clampedRisk
                            if distR >= 2.2 and distR <= 4.5
                                if na(bestMag) or opp.level > bestMag
                                    bestMag := opp.level
                        if not na(bestMag)
                            tp3P    := bestMag
                            tp3RVal := math.round((entryP - bestMag) / clampedRisk, 1)
                            isMag   := true

                int   swLeftTime = math.max(sweepWindowTime, sDir == 1 ? sweptSslTime : sweptBslTime)
                float swTop  = sDir == 1 ? sweptSslLvl : math.max(high, nz(sweptBslOuter, high))
                float swBot  = sDir == 1 ? math.min(low, nz(sweptSslOuter, low)) : sweptBslLvl
                float absVal = sDir == 1 ? buyerAbsorbVal : sellerAbsorbVal

                SavedPlan np = SavedPlan.new(
                     eIdx, sDir, bar_index, entryP, finalSl, fin

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

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

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

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

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

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

Стоимость полного кода
3 357,30₽ ≈ $41.17