Please convert Pure Price Action Liquidity Sweeps

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #251107 quote
    yasyas
    Participant
    Junior

    // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
    // © LuxAlgo

    //@version=5
    indicator(‘Pure Price Action Liquidity Sweeps [LuxAlgo]’, ‘LuxAlgo – Pure Price Action Liquidity Sweeps’, true, max_lines_count=500, max_boxes_count=500)
    //———————————————————————————————————————
    // Settings
    //———————————————————————————————————————{
    term = input.string(‘Long Term’, ‘Detection’, options = [‘Short Term’, ‘Intermediate Term’, ‘Long Term’], display = display.all – display.status_line)

    //Style
    colBl = input.color(#089981, ‘Bullish Level’, inline=’c1′, group = ‘Style’)
    colBlS = input.color(#08998180, ‘Sweep’, inline=’c1′, group = ‘Style’)

    colBr = input.color(#f23645, ‘Bearish Level’ , inline=’c2′, group = ‘Style’)
    colBrS = input.color(#f2364580, ‘Sweep’ , inline=’c2′, group = ‘Style’)

    //———————————————————————————————————————}
    // User Defined Types
    //———————————————————————————————————————{
    type piv
    float prc
    int bix
    bool mit
    bool wic
    line lin

    type boxBr
    box bx
    int dr

    type swing
    float y = na
    int x = na

    type vector
    array<swing> v

    //———————————————————————————————————————}
    // Variables
    //———————————————————————————————————————{
    n = bar_index

    depth = switch term
    ‘Short Term’ => 1
    ‘Intermediate Term’ => 2
    ‘Long Term’ => 3

    //———————————————————————————————————————}
    // Functions / Methods
    //———————————————————————————————————————{
    method l(piv get, color c) =>
    line.new(get.bix, get.prc, n, get.prc, color=c, style = line.style_solid)

    method br(piv get, color c, int d) =>
    y1 = d == 1 ? high : get.prc
    y2 = d == 1 ? get.prc : low
    boxBr.new(box.new(n -1, y1, n +1, y2, border_color = color(na), bgcolor=c), d)

    method detect(array<vector> id, mode, depth)=>
    var swing swingLevel = swing.new(na, na)
    for i = 0 to depth-1
    get_v = id.get(i).v

    if get_v.size() == 3
    pivot = switch mode
    ‘bull’ => math.max(get_v.get(0).y, get_v.get(1).y, get_v.get(2).y)
    ‘bear’ => math.min(get_v.get(0).y, get_v.get(1).y, get_v.get(2).y)

    if pivot == get_v.get(1).y
    if i < depth-1
    id.get(i+1).v.unshift(get_v.get(1))

    if id.get(i+1).v.size() > 3
    id.get(i+1).v.pop()
    else
    swingLevel := swing.new(get_v.get(1).y, get_v.get(1).x)

    get_v.pop()
    get_v.pop()
    swingLevel

    //———————————————————————————————————————}
    // Calculations
    //———————————————————————————————————————{
    var fh = array.new<vector>(0)
    var fl = array.new<vector>(0)

    //Detect swings
    if barstate.isfirst
    for i = 0 to depth-1
    fh.push(vector.new(array.new<swing>(0)))
    fl.push(vector.new(array.new<swing>(0)))

    fh.get(0).v.unshift(swing.new(high, n))
    fl.get(0).v.unshift(swing.new(low, n))

    if fh.get(0).v.size() > 3
    fh.get(0).v.pop()

    if fl.get(0).v.size() > 3
    fl.get(0).v.pop()

    top = fh.detect(‘bull’, depth)
    btm = fl.detect(‘bear’, depth)

    ph = top.y
    pl = btm.y

    //Handle swing levels
    var array<piv> aPivH = array.new<piv>(1, piv.new())
    var array<piv> aPivL = array.new<piv>(1, piv.new())
    var array<boxBr> aBoxBr = array.new<boxBr>(1, boxBr.new())

    if ph > 0 and ph != ph[1]
    aPivH.unshift(piv.new(ph, top.x, false, false))

    if pl > 0 and pl != pl[1]
    aPivL.unshift(piv.new(pl, btm.x, false, false))

    //Test for bearish sweeps/detect breaks
    for i = aPivH.size() -1 to 0
    get = aPivH.get(i)
    if not get.mit
    if close > get.prc
    get.mit := true
    if not get.wic
    if high > get.prc and close < get.prc
    aBoxBr.unshift(get.br(colBrS, 1))
    get.l(colBr)
    get.wic := true

    //Remove old levels
    if n – get.bix > 2000 or get.mit
    aPivH.remove(i).lin.delete()

    //Test for bullish sweeps/detect breaks
    for i = aPivL.size() -1 to 0
    get = aPivL.get(i)
    if not get.mit
    if close < get.prc
    get.mit := true
    if not get.wic
    if low < get.prc and close > get.prc
    aBoxBr.unshift(get.br(colBlS, -1))
    get.l(colBl)
    get.wic := true

    //Remove old levels
    if n – get.bix > 2000 or get.mit
    aPivL.remove(i).lin.delete()

    //———————————————————————————————————————}

    #251635 quote
    Iván GonzálezIván González
    Moderator
    Legend

    voici!

    //---------------------------------------------------//
    //PRC_Pure Price Action Liquidity Sweeps (by LuxAlgo)
    //version = 0
    //23.09.25
    //Iván González @ www.prorealcode.com
    //---------------------------------------------------//
    // --- Configuración (Variables personalizables) --- //
    //---------------------------------------------------//
    // Detección: 1 = Corto Plazo, 2 = Plazo Intermedio, 3 = Largo Plazo
    profundidad = 1
    // Límite de líneas de liquidez (máximos y mínimos) a mostrar en el gráfico
    maxLineas = 40
    // Límite de barras para mantener un nivel de pivote activo en el gráfico
    limiteBarras = 2000
    // Colores (formato RGB: Rojo, Verde, Azul, Opacidad)
    RedAlcista = 8
    GreenAlcista = 153
    BlueAlcista = 129
    AlphaAlcista = 255
    AlphaBarridoAlcista = 80
    RedBajista = 242
    GreenBajista = 54
    BlueBajista = 69
    AlphaBajista = 255
    AlphaBarridoBajista = 80
    //---------------------------------------------------//
    // -------------- Lógica de Pivotes ---------------- //
    //---------------------------------------------------//
    
    IF profundidad = 1 THEN // (Short Term)
       periodoPivote = 5
       offset = 2
    ELSIF profundidad = 2 THEN // (Mid Term)
       periodoPivote = 13
       offset = 6
    ELSE // profundidad = 3 (Long Term)
       periodoPivote = 21
       offset = 10
    ENDIF
    //---------------------------------------------------//
    // ----- Inicialización y Detección de Pivotes ----- //
    //---------------------------------------------------//
    
    ONCE pivHCount = 0
    ONCE pivLCount = 0
    
    ph = 0
    pl = 0
    
    // Detectar pivote de máximo (Pivot High)
    IF high[offset] = HIGHEST[periodoPivote](high) THEN
       ph = high[offset]
    ENDIF
    
    // Detectar pivote de mínimo (Pivot Low)
    IF low[offset] = LOWEST[periodoPivote](low) THEN
       pl = low[offset]
    ENDIF
    
    // Almacenar nuevo pivote de máximo
    IF ph > 0 AND (pivHCount = 0 OR ph <> $pivHPrc[max(0,pivHCount - 1)]) THEN
       $pivHPrc[pivHCount] = ph
       $pivHBix[pivHCount] = barindex - offset
       pivHCount = pivHCount + 1
    ENDIF
    
    // Almacenar nuevo pivote de mínimo
    IF pl > 0 AND (pivLCount = 0 OR pl <> $pivLPrc[max(0,pivLCount - 1)]) THEN
       $pivLPrc[pivLCount] = pl
       $pivLBix[pivLCount] = barindex - offset
       pivLCount = pivLCount + 1
    ENDIF
    
    //---------------------------------------------------//
    // ------- Lógica de Procesamiento y Dibujo -------- //
    //---------------------------------------------------//
    
    IF ISLASTBARUPDATE THEN
       // --- PROCESAMIENTO DE PIVOTES DE MÁXIMOS (BARRIDOS BAJISTAS)
       lineasDibujadasH = 0
       FOR i = pivHCount - 1 DOWNTO 0
          IF lineasDibujadasH >= maxLineas THEN
             BREAK
          ENDIF
          IF barindex - $pivHBix[i] < limiteBarras THEN
             esMitigado = 0
             esBarrido = 0
             indiceBarrido = -1
             maximoBarrido = 0
             FOR j = $pivHBix[i] + 1 TO barindex
                IF close[barindex-j] > $pivHPrc[i] THEN
                   esMitigado = 1
                   BREAK
                ENDIF
                IF high[barindex-j] > $pivHPrc[i] AND close[barindex-j] < $pivHPrc[i] THEN
                   esBarrido = 1
                   indiceBarrido = j
                   maximoBarrido = high[barindex-j]
                   BREAK
                ENDIF
             NEXT
             IF esMitigado = 0 THEN
                lineasDibujadasH = lineasDibujadasH + 1
                IF esBarrido THEN
                   DRAWSEGMENT($pivHBix[i], $pivHPrc[i], indiceBarrido, $pivHPrc[i]) STYLE(Line, 1) COLOURED(RedBajista,GreenBajista,BlueBajista,AlphaBajista)
                   DRAWRECTANGLE(indiceBarrido - 1, maximoBarrido, indiceBarrido + 1, $pivHPrc[i]) COLOURED(RedBajista,GreenBajista,BlueBajista,AlphaBarridoBajista)
                ELSE
                   DRAWSEGMENT($pivHBix[i], $pivHPrc[i], barindex, $pivHPrc[i]) STYLE(dottedLine, 1) COLOURED(RedBajista,GreenBajista,BlueBajista,AlphaBarridoBajista)
                ENDIF
             ENDIF
          ENDIF
       NEXT
       
       // --- PROCESAMIENTO DE PIVOTES DE MÍNIMOS (BARRIDOS ALCISTAS)
       lineasDibujadasL = 0
       FOR i = pivLCount - 1 DOWNTO 0
          IF lineasDibujadasL >= maxLineas THEN
             BREAK
          ENDIF
          IF barindex - $pivLBix[i] < limiteBarras THEN
             esMitigado = 0
             esBarrido = 0
             indiceBarrido = -1
             minimoBarrido = 0
             FOR j = $pivLBix[i] + 1 TO barindex
                IF close[barindex-j] < $pivLPrc[i] THEN
                   esMitigado = 1
                   BREAK
                ENDIF
                IF low[barindex-j] < $pivLPrc[i] AND close[barindex-j] > $pivLPrc[i] THEN
                   esBarrido = 1
                   indiceBarrido = j
                   minimoBarrido = low[barindex-j]
                   BREAK
                ENDIF
             NEXT
             IF esMitigado = 0 THEN
                lineasDibujadasL = lineasDibujadasL + 1
                IF esBarrido THEN
                   DRAWSEGMENT($pivLBix[i], $pivLPrc[i], indiceBarrido, $pivLPrc[i]) STYLE(Line, 1) COLOURED(RedAlcista,GreenAlcista,BlueAlcista,AlphaAlcista)
                   DRAWRECTANGLE(indiceBarrido - 1, $pivLPrc[i], indiceBarrido + 1, minimoBarrido) COLOURED(RedAlcista,GreenAlcista,BlueAlcista,AlphaBarridoAlcista)
                ELSE
                   DRAWSEGMENT($pivLBix[i], $pivLPrc[i], barindex, $pivLPrc[i]) STYLE(dottedLine, 1) COLOURED(RedAlcista,GreenAlcista,BlueAlcista,AlphaBarridoAlcista)
                ENDIF
             ENDIF
          ENDIF
       NEXT
    ENDIF
    //---------------------------------------------------//
    RETURN
    
    #251639 quote
    yasyas
    Participant
    Junior

    Many thanks mate much appreciated

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Please convert Pure Price Action Liquidity Sweeps


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
yas @yas Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by yasyas
12 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/18/2025
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...