Traduction Code pine tradingwiew (Order Block)

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #225935 quote
    larouedegann
    Participant
    Master

    Bonjour,
    Veuillez trouver ci-dessous le code pine “ORDER BLOCK DETECTOR” de luxalgo
    Est-ce qu’on peut le traduire en PRT ?

    merci

    /@version=5
    indicator(“Order Block Detector [LuxAlgo]”
    , overlay = true
    , max_boxes_count = 500
    , max_labels_count = 500
    , max_lines_count = 500)
    //——————————————————————————
    //Settings
    //—————————————————————————–{
    length = input.int(5, ‘Volume Pivot Length’
    , minval = 1)

    bull_ext_last = input.int(3, ‘Bullish OB ’
    , minval = 1
    , inline = ‘bull’)

    bg_bull_css = input.color(color.new(#169400, 80), ”
    , inline = ‘bull’)

    bull_css = input.color(#169400, ”
    , inline = ‘bull’)

    bull_avg_css = input.color(color.new(#9598a1, 37), ”
    , inline = ‘bull’)

    bear_ext_last = input.int(3, ‘Bearish OB’
    , minval = 1
    , inline = ‘bear’)

    bg_bear_css = input.color(color.new(#ff1100, 80), ”
    , inline = ‘bear’)

    bear_css = input.color(#ff1100, ”
    , inline = ‘bear’)

    bear_avg_css = input.color(color.new(#9598a1, 37), ”
    , inline = ‘bear’)

    line_style = input.string(‘⎯⎯⎯’, ‘Average Line Style’
    , options = [‘⎯⎯⎯’, ‘—-‘, ‘····’])

    line_width = input.int(1, ‘Average Line Width’
    , minval = 1)

    mitigation = input.string(‘Wick’, ‘Mitigation Methods’
    , options = [‘Wick’, ‘Close’])

    //—————————————————————————–}
    //Functions
    //—————————————————————————–{
    //Line Style function
    get_line_style(style) =>
    out = switch style
    ‘⎯⎯⎯’ => line.style_solid
    ‘—-‘ => line.style_dashed
    ‘····’ => line.style_dotted

    //Function to get order block coordinates
    get_coordinates(condition, top, btm, ob_val)=>
    var ob_top = array.new_float(0)
    var ob_btm = array.new_float(0)
    var ob_avg = array.new_float(0)
    var ob_left = array.new_int(0)

    float ob = na

    //Append coordinates to arrays
    if condition
    avg = math.avg(top, btm)

    array.unshift(ob_top, top)
    array.unshift(ob_btm, btm)
    array.unshift(ob_avg, avg)
    array.unshift(ob_left, time[length])

    ob := ob_val

    [ob_top, ob_btm, ob_avg, ob_left, ob]

    //Function to remove mitigated order blocks from coordinate arrays
    remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=>
    mitigated = false
    target_array = bull ? ob_btm : ob_top

    for element in target_array
    idx = array.indexof(target_array, element)

    if (bull ? target < element : target > element)
    mitigated := true

    array.remove(ob_top, idx)
    array.remove(ob_btm, idx)
    array.remove(ob_avg, idx)
    array.remove(ob_left, idx)

    mitigated

    //Function to set order blocks
    set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=>
    var ob_box = array.new_box(0)
    var ob_lvl = array.new_line(0)

    //Fill arrays with boxes/lines
    if barstate.isfirst
    for i = 0 to ext_last-1
    array.unshift(ob_box, box.new(na,na,na,na
    , xloc = xloc.bar_time
    , extend= extend.right
    , bgcolor = bg_css
    , border_color = color.new(border_css, 70)))

    array.unshift(ob_lvl, line.new(na,na,na,na
    , xloc = xloc.bar_time
    , extend = extend.right
    , color = lvl_css
    , style = get_line_style(line_style)
    , width = line_width))

    //Set order blocks
    if barstate.islast
    if array.size(ob_top) > 0
    for i = 0 to math.min(ext_last-1, array.size(ob_top)-1)
    get_box = array.get(ob_box, i)
    get_lvl = array.get(ob_lvl, i)

    box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i))
    box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i))

    line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i))
    line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i))

    //—————————————————————————–}
    //Global elements
    //—————————————————————————–{
    var os = 0
    var target_bull = 0.
    var target_bear = 0.

    n = bar_index
    upper = ta.highest(length)
    lower = ta.lowest(length)

    if mitigation == ‘Close’
    target_bull := ta.lowest(close, length)
    target_bear := ta.highest(close, length)
    else
    target_bull := lower
    target_bear := upper

    os := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1] phv = ta.pivothigh(volume, length, length) //-----------------------------------------------------------------------------} //Get bullish/bearish order blocks coordinates //-----------------------------------------------------------------------------{ [bull_top , bull_btm , bull_avg , bull_left , bull_ob] = get_coordinates(phv and os == 1, hl2[length], low[length], low[length]) [bear_top , bear_btm , bear_avg , bear_left , bear_ob] = get_coordinates(phv and os == 0, high[length], hl2[length], high[length]) //-----------------------------------------------------------------------------} //Remove mitigated order blocks //-----------------------------------------------------------------------------{ mitigated_bull = remove_mitigated(bull_top , bull_btm , bull_left , bull_avg , target_bull , true) mitigated_bear = remove_mitigated(bear_top , bear_btm , bear_left , bear_avg , target_bear , false) //-----------------------------------------------------------------------------} //Display order blocks //-----------------------------------------------------------------------------{ //Set bullish order blocks set_order_blocks(bull_top , bull_btm , bull_left , bull_avg , bull_ext_last , bg_bull_css , bull_css , bull_avg_css) //Set bearish order blocks set_order_blocks(bear_top , bear_btm , bear_left , bear_avg , bear_ext_last , bg_bear_css , bear_css , bear_avg_css) //Show detected order blocks plot(bull_ob, 'Bull OB', bull_css, 2, plot.style_linebr , offset = -length , display = display.none) plot(bear_ob, 'Bear OB', bear_css, 2, plot.style_linebr , offset = -length , display = display.none) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ alertcondition(bull_ob, 'Bullish OB Formed', 'Bullish order block detected') alertcondition(bear_ob, 'Bearish OB Formed', 'bearish order block detected') alertcondition(mitigated_bull, 'Bullish OB Mitigated', 'Bullish order block mitigated') alertcondition(mitigated_bear, 'Bearish OB Mitigated', 'bearish order block mitigated') //-----------------------------------------------------------------------------}

    #225936 quote
    larouedegann
    Participant
    Master
    /@version=5
    indicator("Order Block Detector [LuxAlgo]"
      , overlay = true
      , max_boxes_count = 500
      , max_labels_count = 500
      , max_lines_count = 500)
    //------------------------------------------------------------------------------
    //Settings
    //-----------------------------------------------------------------------------{
    length = input.int(5, 'Volume Pivot Length'
      , minval = 1)
    
    bull_ext_last = input.int(3, 'Bullish OB '
      , minval = 1
      , inline = 'bull')
    
    bg_bull_css = input.color(color.new(#169400, 80), ''
      , inline = 'bull')
    
    bull_css = input.color(#169400, ''
      , inline = 'bull')
    
    bull_avg_css = input.color(color.new(#9598a1, 37), ''
      , inline = 'bull')
    
    bear_ext_last = input.int(3, 'Bearish OB'
      , minval = 1
      , inline = 'bear')
    
    bg_bear_css = input.color(color.new(#ff1100, 80), ''
      , inline = 'bear')
    
    bear_css = input.color(#ff1100, ''
      , inline = 'bear')
    
    bear_avg_css = input.color(color.new(#9598a1, 37), ''
      , inline = 'bear')
    
    line_style = input.string('⎯⎯⎯', 'Average Line Style'
      , options = ['⎯⎯⎯', '----', '····'])
    
    line_width = input.int(1, 'Average Line Width'
      , minval = 1)
    
    mitigation = input.string('Wick', 'Mitigation Methods'
      , options = ['Wick', 'Close'])
    
    //-----------------------------------------------------------------------------}
    //Functions 
    //-----------------------------------------------------------------------------{
    //Line Style function
    get_line_style(style) =>
        out = switch style
            '⎯⎯⎯'  => line.style_solid
            '----' => line.style_dashed
            '····' => line.style_dotted
    
    //Function to get order block coordinates
    get_coordinates(condition, top, btm, ob_val)=>
        var ob_top  = array.new_float(0)
        var ob_btm  = array.new_float(0)
        var ob_avg  = array.new_float(0)
        var ob_left = array.new_int(0)
    
        float ob = na
    
        //Append coordinates to arrays
        if condition
            avg = math.avg(top, btm)
            
            array.unshift(ob_top, top)
            array.unshift(ob_btm, btm)
            array.unshift(ob_avg, avg)
            array.unshift(ob_left, time[length])
            
            ob := ob_val
        
        [ob_top, ob_btm, ob_avg, ob_left, ob]
    
    //Function to remove mitigated order blocks from coordinate arrays
    remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=>
        mitigated = false
        target_array = bull ? ob_btm : ob_top
    
        for element in target_array
            idx = array.indexof(target_array, element)
    
            if (bull ? target < element : target > element)
                mitigated := true
    
                array.remove(ob_top, idx)
                array.remove(ob_btm, idx)
                array.remove(ob_avg, idx)
                array.remove(ob_left, idx)
        
        mitigated
    
    //Function to set order blocks
    set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=>
        var ob_box = array.new_box(0)
        var ob_lvl = array.new_line(0)
    
        //Fill arrays with boxes/lines
        if barstate.isfirst
            for i = 0 to ext_last-1
                array.unshift(ob_box, box.new(na,na,na,na
                  , xloc = xloc.bar_time
                  , extend= extend.right
                  , bgcolor = bg_css
                  , border_color = color.new(border_css, 70)))
    
                array.unshift(ob_lvl, line.new(na,na,na,na
                  , xloc = xloc.bar_time
                  , extend = extend.right
                  , color = lvl_css
                  , style = get_line_style(line_style)
                  , width = line_width))
    
        //Set order blocks
        if barstate.islast
            if array.size(ob_top) > 0
                for i = 0 to math.min(ext_last-1, array.size(ob_top)-1)
                    get_box = array.get(ob_box, i)
                    get_lvl = array.get(ob_lvl, i)
    
                    box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i))
                    box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i))
    
                    line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i))
                    line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i))
    
    
    //-----------------------------------------------------------------------------}
    //Global elements 
    //-----------------------------------------------------------------------------{
    var os = 0
    var target_bull = 0.
    var target_bear = 0.
    
    n = bar_index
    upper = ta.highest(length)
    lower = ta.lowest(length)
    
    if mitigation == 'Close'
        target_bull := ta.lowest(close, length)
        target_bear := ta.highest(close, length)
    else
        target_bull := lower
        target_bear := upper
    
    os := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1]
    
    phv = ta.pivothigh(volume, length, length)
    
    //-----------------------------------------------------------------------------}
    //Get bullish/bearish order blocks coordinates 
    //-----------------------------------------------------------------------------{
    [bull_top
      , bull_btm
      , bull_avg
      , bull_left
      , bull_ob] = get_coordinates(phv and os == 1, hl2[length], low[length], low[length])
    
    [bear_top
      , bear_btm
      , bear_avg
      , bear_left
      , bear_ob] = get_coordinates(phv and os == 0, high[length], hl2[length], high[length])
    
    //-----------------------------------------------------------------------------}
    //Remove mitigated order blocks
    //-----------------------------------------------------------------------------{
    mitigated_bull = remove_mitigated(bull_top
      , bull_btm
      , bull_left
      , bull_avg
      , target_bull
      , true)
    
    mitigated_bear = remove_mitigated(bear_top
      , bear_btm
      , bear_left
      , bear_avg
      , target_bear
      , false)
    
    //-----------------------------------------------------------------------------}
    //Display order blocks
    //-----------------------------------------------------------------------------{
    //Set bullish order blocks
    set_order_blocks(bull_top
      , bull_btm
      , bull_left
      , bull_avg
      , bull_ext_last
      , bg_bull_css
      , bull_css
      , bull_avg_css)
    
    //Set bearish order blocks
    set_order_blocks(bear_top
      , bear_btm
      , bear_left
      , bear_avg
      , bear_ext_last
      , bg_bear_css
      , bear_css
      , bear_avg_css)
            
    //Show detected order blocks
    plot(bull_ob, 'Bull OB', bull_css, 2, plot.style_linebr
      , offset = -length
      , display = display.none)
    
    plot(bear_ob, 'Bear OB', bear_css, 2, plot.style_linebr
      , offset = -length
      , display = display.none)
    
    //-----------------------------------------------------------------------------}
    //Alerts
    //-----------------------------------------------------------------------------{
    alertcondition(bull_ob, 'Bullish OB Formed', 'Bullish order block detected')
    
    alertcondition(bear_ob, 'Bearish OB Formed', 'bearish order block detected')
    
    alertcondition(mitigated_bull, 'Bullish OB Mitigated', 'Bullish order block mitigated')
    
    alertcondition(mitigated_bear, 'Bearish OB Mitigated', 'bearish order block mitigated')
    
    //-----------------------------------------------------------------------------}
    #226064 quote
    larouedegann
    Participant
    Master

    Personne pour une traduction code pine ?

    #226272 quote
    yas
    Participant
    Junior

    can someone convert the above code into pro real time please

    #229903 quote
    larouedegann
    Participant
    Master

    Toujours personne ?

    #230056 quote
    paulPRT
    Participant
    New

    Bonjour,

    As tu essayé de le traduire en utilisant chat gpt ?

    #230064 quote
    yas
    Participant
    Junior

    i used the Chat gpt to convert but its got error on line 1 if someone can tell please here is the code for the above

    //Settings
    length = 5
    bull_ext_last = 3
    bg_bull_css = RGB(22, 148, 0, 80)
    bull_css = RGB(22, 148, 0)
    bull_avg_css = RGB(149, 152, 161, 37)
    bear_ext_last = 3
    bg_bear_css = RGB(255, 17, 0, 80)
    bear_css = RGB(255, 17, 0)
    bear_avg_css = RGB(149, 152, 161, 37)
    line_style = 0 // 0 for solid line, 1 for dashed line, 2 for dotted line
    line_width = 1
    mitigation = 0 // 0 for Wick, 1 for Close
    
    //Functions
    get_line_style(style) =>
        out = IIF(style = 0, linestyle.solid, IIF(style = 1, linestyle.dashed, linestyle.dotted))
    
    get_coordinates(condition, top, btm, ob_val)=>
        var ob_top[500]
        var ob_btm[500]
        var ob_avg[500]
        var ob_left[500]
        var ob = 0.0
        
        if condition then
            avg = (top + btm) / 2
            
            ob_top[0] := top
            ob_btm[0] := btm
            ob_avg[0] := avg
            ob_left[0] := time[length]
            
            ob := ob_val
        
        [ob_top, ob_btm, ob_avg, ob_left, ob]
    
    remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=>
        mitigated = FALSE
        target_array = bull ? ob_btm : ob_top
        
        for i = 0 to ArraySize(target_array) - 1
            if (bull ? target < target_array[i] : target > target_array[i]) then
                mitigated := TRUE
                
                ArrayDelete(ob_top, i)
                ArrayDelete(ob_btm, i)
                ArrayDelete(ob_avg, i)
                ArrayDelete(ob_left, i)
        
        mitigated
    
    set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=>
        var ob_box[500]
        var ob_lvl[500]
        
        if barindex = 1 then
            for i = 0 to ext_last - 1
                ob_box[i] := CreateBox(na, na, na, na
                  , xloc = xloc.bar_time
                  , extend = extend.right
                  , bgcolor = bg_css
                  , border_color = color.new(border_css, 70))
     
                ob_lvl[i] := CreateLine(na, na, na, na
                  , xloc = xloc.bar_time
                  , extend = extend.right
                  , color = lvl_css
                  , style = get_line_style(line_style)
                  , width = line_width)
     
        if lastbaronchart then
            for i = 0 to Min(ext_last - 1, ArraySize(ob_top) - 1)
                box.SetLeftTop(ob_box[i], ob_left[i], ob_top[i])
                box.SetRightBottom(ob_box[i], ob_left[i], ob_btm[i])
     
                line.SetXY1(ob_lvl[i], ob_left[i], ob_avg[i])
                line.SetXY2(ob_lvl[i], ob_left[i] + 1, ob_avg[i])
    
    //Global elements
    var os = 0
    var target_bull = 0.0
    var target_bear = 0.0
     
    n = barindex
    upper = Highest[length]
    lower = Lowest[length]
     
    if mitigation = 1 then
        target_bull := Lowest[1](close[length])
        target_bear := Highest[1](close[length])
    else
        target_bull := lower
        target_bear := upper
     
    os := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1]
     
    phv = PivotHigh(volume, length, length)
    
    //Get bullish/bearish order blocks coordinates
    [bull_top, bull_btm, bull_avg, bull_left, bull_ob] = get_coordinates(phv and os = 1, hl2[length], low[length], low[length])
    [bear_top, bear_btm, bear_avg, bear_left, bear_ob] = get_coordinates(phv and os = 0, high[length], hl2[length], high[length])
    
    //Remove mitigated order blocks
    mitigated_bull = remove_mitigated(bull_top, bull_btm, bull_left, bull_avg, target_bull, TRUE)
    mitigated_bear = remove_mitigated(bear_top, bear_btm, bear_left, bear_avg, target_bear, FALSE)
    
    //Display order blocks
    set_order_blocks(bull_top, bull_btm, bull_left, bull_avg, bull_ext_last, bg_bull_css, bull_css, bull_avg_css)
    set_order_blocks(bear_top, bear_btm, bear_left, bear_avg, bear_ext_last, bg_bear_css, bear_css, bear_avg_css)
    
    //Alerts
    AlertIf(bull_ob, "Bullish OB Formed", "Bullish order block detected")
    AlertIf(bear_ob, "Bearish OB Formed", "Bearish order block detected")
    AlertIf(mitigated_bull, "Bullish OB Mitigated", "Bullish order block mitigated")
    AlertIf(mitigated_bear, "Bearish OB Mitigated", "Bearish order block mitigated")
    #232052 quote
    Iván González
    Moderator
    Master

    Hola Aquí a une approximation.

    //-----Settings---------------------------------------------------------//
    length = 5 //Volume Pivot Length
    bullextlast = 3 //Bullish OB
    bearextlast = 3 //Bearish OB
    mitigation = 0 //0=Wick 1=Close
    //----------------------------------------------------------------------//
    //-----Global elements--------------------------------------------------//
    n=barindex
    
    upper = highest[length](high)
    lower = lowest[length](low)
    
    if mitigation then
    targetbull = lowest[length](close)
    targetbear = highest[length](close)
    else
    targetbull = lower
    targetbear = upper
    endif
    
    if high[length] > upper then
    os = 0
    elsif low[length] < lower then
    os = 1
    else
    os = os[1]
    endif
    
    if volume < volume[length] and highest[length](volume)<volume[length] and volume[length]>highest[length](volume)[length+1] then
    $phvol[t+1]=volume[length]
    $phvolx[t+1]=barindex[length]
    t=t+1
    endif
    phv = $phvol[t]
    //----------------------------------------------------------------------//
    //-----Get bullish/bearish order blocks coordinates---------------------//
    if isset($phvol[t]) and phv<>phv[1] and os=1 then
    $bulltop[m+1] = (high[length]+low[length])/2
    $bullbtm[m+1] = low[length]
    $bullavg[m+1] = ((high[length]+low[length])/2+low[length])/2
    $bullleft[m+1] = barindex-length
    $bullob[m+1] = low[length]
    m=m+1
    endif
    
    if isset($phvol[t]) and phv<>phv[1] and os=0 then
    $beartop[r+1] = high[length]
    $bearbtm[r+1] = (high[length]+low[length])/2
    $bearavg[r+1] = ((high[length]+low[length])/2+high[length])/2
    $bearleft[r+1] = barindex-length
    $bearob[r+1] = high[length]
    r=r+1
    endif
    //----------------------------------------------------------------------//
    //remove_mitigated
    if islastbarupdate then
    t=0
    for i=m downto 0 do
    if targetbull > $bullbtm[i] then
    $bullishTOP[T+1] = $bulltop[i]
    $bullishBOT[T+1] = $bullbtm[i]
    $bullishAVG[T+1] = $bullavg[i]
    $bullishLEFT[T+1] = $bullleft[i]
    t=t+1
    drawrectangle($bullishLEFT[t],$bullishTOP[t],barindex,$bullishBOT[t])coloured("green")fillcolor("green",70)
    if t >= bullextlast then
    break
    endif
    endif
    next
    //----------------------------------------------------------------------//
    k=0
    for j=r downto 0 do
    if targetbear < $beartop[j] then
    $bearishtop[k+1]=$beartop[j]
    $bearishbot[k+1]=$bearbtm[j]
    $bearishavg[k+1]=$bearavg[j]
    $bearishleft[k+1]=$bearleft[j]
    k=k+1
    drawrectangle($bearishleft[k],$bearishtop[k],barindex,$bearishbot[k])coloured("red")fillcolor("red",70)
    if k >= bearextlast then
    break
    endif
    endif
    next
    endif
    //----------------------------------------------------------------------//
    return
    
    Mprorealcode and LucasBest thanked this post
    #232251 quote
    larouedegann
    Participant
    Master

    Merci à toi ivan

    #233259 quote
    LucasBest
    Participant
    Junior

    Ce pourrait être intéressant de traduire cette ordre indicateur qui ressemble à celui-ci mais qui prend en compte le RSI plutôt que le volume…
    https://fr.tradingview.com/script/mEkpXvxO-RSI-Order-Blocks-UAlgo/

    “RSI-based Order Block Identification: The script utilizes the RSI indicator to identify potential order blocks. It detects pivot highs and lows in the RSI, which are indicative of potential reversal points, and marks these areas as potential order blocks.”

    https://www.tradingview.com/x/OJZl1RH4

    #233277 quote
    Iván González
    Moderator
    Master

    Salut. Oui, je pourrais faire la traduction, mais j'ai besoin que vous créiez un nouveau sujet ou directement depuis ici : https://www.prorealcode.com/free-code-conversion/

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

Traduction Code pine tradingwiew (Order Block)


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 10 replies,
has 5 voices, and was last updated by Iván González
1 year, 8 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 01/03/2024
Status: Active
Attachments: No files
Logo Logo
Loading...