Support and Resistance Power Channel

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #259866 quote
    Ball
    Participant
    New

    Bonjour

    Je cherche à coder pour Prorealtime l’indicateur Support and Resistance Power Channel de ChartPrime en pinescript sur Tradingview.

    Quelqu’un peut-il m’aider ?

    Merci d’avance

    Abbip


    #259871 quote
    Ball
    Participant
    New

    Voici le code Pine Script de l’indicateur à coder pour PRT

    // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

    // © ChartPrime


    //@version=5

    indicator(“Support and Resistance Power Channel [ChartPrime]”, “S&R Power [ChartPrime]”, overlay = true, max_labels_count = 12, max_bars_back = 500)


    // ——————————————————————————————————————–}

    // 𝙐𝙎𝙀𝙍 𝙄𝙉𝙋𝙐𝙏𝙎

    // ——————————————————————————————————————–{


    int length = input.int(130)

    int extend = input.int(30, minval = 20, maxval = 100)


    color t_col = input.color(color.fuchsia, “Top”, inline = “col”)

    color b_col = input.color(color.lime, “Bottom”, inline = “col”)


    type data

        line sup      = na

        line res      = na

        box  sup_area = na 

        box  res_area = na 


    // ——————————————————————————————————————–}

    // 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎

    // ——————————————————————————————————————–{


    max_min(length, d)=>

        var max = array.new<float>(length) 

        var min = array.new<float>(length) 


        if barstate.islast

            for i = 0 to length  1

                max.set(i,high[i])

                min.set(i,low[i]) 


            if max.size() > length*2

                max.shift()

                min.shift()


            float max_ = max.max()

            float min_ = min.min()

            float mid_ = math.avg(max_, min_)


            label.delete(

             label.new(bar_index+extend+15, max_, str.tostring(max_, “🡅 #.##”), color = color(na), style = label.style_label_center, textcolor = chart.fg_color)[1]

             )

            label.delete(        

             label.new(bar_index+extend+15, min_, str.tostring(min_, “🡇 #.##”), color = color(na), style = label.style_label_center, textcolor = chart.fg_color)[1]

             )

            label.delete(        

             label.new(bar_index+extend, mid_, str.tostring(mid_, “🡆 #.##”), color = color(na), style = label.style_label_left, textcolor = color.gray)[1]

             )

            line.delete(

             line.new(bar_indexlength, mid_, bar_index+extend, mid_, color = color.gray, style = line.style_dotted)[1]

             )


            index_of_max = max.indexof(max_)

            index_of_min = min.indexof(min_)


            label.delete( 

             label.new(bar_index[index_of_max], max_, “✖”, color = color(na), textcolor = t_col, size = size.normal, style = label.style_label_center)[1]

             )

            label.delete( 

             label.new(bar_index[index_of_min], min_, “✖”, color = color(na), textcolor = b_col, size = size.normal, style = label.style_label_center)[1]

             )

        [max.max(), min.min()]



    delte_(data d)=>

        line.delete(d.sup[1])

        line.delete(d.res[1])

        box.delete(d.sup_area[1])

        box.delete(d.res_area[1])


    power(d)=>

        int buy  = 0

        int sell = 0


        if barstate.islast

            for i = 0 to length  1

                buy += (close[i] > open[i] ? 1 : 0)

                sell += (close[i] < open[i] ? 1 : 0)


        d.sup_area.set_text(str.tostring(buy, ”            Buy Power: #”))

        d.res_area.set_text(str.tostring(sell, ”            Sell Power: #”))


        d.res_area.set_text_color(chart.fg_color)

        d.sup_area.set_text_color(chart.fg_color)

        d.res_area.set_text_halign(text.align_left)

        d.sup_area.set_text_halign(text.align_left)

        d.res_area.set_text_size(size.normal)

        d.sup_area.set_text_size(size.normal)



    signals(d)=>

        if barstate.islast

            for i = 0 to length -1


                low_1 = low[i]

                low_2 = low[i>0 ? i+1 : i]


                high_1 = high[i]

                high_2 = high[i>0 ? i+1 : i]

                        

                index = bar_indexi

                top = d.sup_area.get_top()

                bot = d.res_area.get_bottom()


                if low_1 > top and low_2 <= top

                    label.new(index, low_2, “◈”, textcolor = b_col, color = color(na), style = label.style_label_up, size = size.large)


                if high_1 < bot and high_2 >= bot

                    label.new(index, high_2, “◈”, textcolor = t_col, color = color(na), style = label.style_label_down, size = size.large)


    run_indicator()=>

        float  atr = ta.atr(200)*0.5

        var data d = data.new(line(na), line(na), box(na), box(na))


        [max, min] = max_min(length, d)

        if barstate.islast

            d.sup := line.new(bar_indexlength, max+atr, bar_index+extend+30, max+atr, color = t_col, style = line.style_solid)

            d.res := line.new(bar_indexlength, minatr, bar_index+extend+30, minatr, color = b_col, style = line.style_solid)


            d.res_area := box.new(bar_indexlength, max+atr, bar_index+extend, maxatr, na, bgcolor = color.new(t_col, 80))

            d.sup_area := box.new(bar_indexlength, min+atr, bar_index+extend, minatr, na, bgcolor = color.new(b_col, 80))


        delte_(d)

        signals(d)

        power(d)



    // ——————————————————————————————————————–}

    // 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉

    // ——————————————————————————————————————–{


    run_indicator()

    #259873 quote
    JS
    Participant
    Veteran
    // -----------------------------------------------
    // PRC_Support and Resistance Power Channel [ChartPrime]
    //version = 0
    //07.10.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    // -----------------------------------------------
    // INPUTS
    // -----------------------------------------------
    DEFPARAM DRAWONLASTBARONLY = true
    length = 130
    extend = 30
    // COLOURS
    tcolR = 255
    tcolG = 0
    tcolB = 255
    bcolR = 0
    bcolG = 255
    bcolB = 0
    alpha = 60
    // -----------------------------------------------
    // CALCULATION SUPPORT AND RESISTANCE AREA
    // -----------------------------------------------
    // ATR
    atr = AverageTrueRange[200] * 0.5
    // HIGHEST AND LOWEST PRICE
    maxVal = HIGHEST[length](high)
    minVal = LOWEST[length](low)
    midVal = (maxVal + minVal) / 2
    // -----------------------------------------------
    // DRAW SUPPORT AND RESISTANCE AREA
    // -----------------------------------------------
    if islastbarupdate then
    maxOffset = barssince(high=maxVal)
    minOffset = barssince(low=minVal)
    // RESISTANCE AREA
    DRAWRECTANGLE(barindex - length, maxVal + atr, barindex + extend, maxVal - atr) fillcolor(tcolR, tcolG, tcolB, alpha)COLOURED(tcolR, tcolG, tcolB,0)
    DRAWSEGMENT(barindex - length, maxVal + atr, barindex + extend + 30, maxVal + atr) COLOURED(tcolR, tcolG, tcolB)
    DRAWTEXT("▲ #maxVal#", barindex + extend + 10, maxVal)
       
    // SUPPORT AREA
    DRAWRECTANGLE(barindex - length, minVal + atr, barindex + extend, minVal - atr) fillcolor(bcolR, bcolG, bcolB, alpha)COLOURED(bcolR, bcolG, bcolB, 0)
    DRAWSEGMENT(barindex - length, minVal - atr, barindex + extend + 30, minVal - atr) COLOURED(bcolR, bcolG, bcolB)
    DRAWTEXT("▼ #minVal#", barindex + extend + 10, minVal)
       
    // MIDDLE LINE
    DRAWSEGMENT(barindex - length, midVal, barindex + extend, midVal) COLOURED(128, 128, 128) STYLE(DOTTEDLINE, 1)
    DRAWTEXT("▶ #midVal#", barindex + extend + 10, midVal) COLOURED(128, 128, 128)
       
    // BUY AND SELL POWER
    buyPower = 0
    sellPower = 0
       
    FOR i = 0 TO length - 1 DO
    IF close[i] > open[i] THEN
    buyPower = buyPower + 1
    ELSIF close[i] < open[i] THEN
    sellPower = sellPower + 1
    ENDIF
    NEXT
       
    textPosX = barindex + round(extend*0.5)
    DRAWTEXT("Sell Power: #sellpower#", textPosX, maxVal)
    DRAWTEXT("Buy Power: #buypower#", textPosX, minVal)
       
    // DRAW SUPPORT AND RESISTANCE TESTS
    topOfSupport = minVal + atr
    bottomOfResistance = maxVal - atr
       
    FOR i = 0 TO length - 1 DO
    IF low[i+1] <= topOfSupport AND low[i] > topOfSupport THEN
    DRAWARROWUP(barindex - i, minval - atr*1.5) COLOURED(bcolR, bcolG, bcolB)
    ENDIF
    IF high[i+1] >= bottomOfResistance AND high[i] < bottomOfResistance THEN
    DRAWARROWDOWN(barindex - i, maxval + 1.5*atr) COLOURED(tcolR, tcolG, tcolB)
    ENDIF
    if high[i]=maxval then
    drawpoint(barindex[i],maxval,3)coloured(tcolR, tcolG, tcolB)
    endif
    if low[i]=minval then
    drawpoint(barindex[i],minval,3)coloured(bcolR, bcolG, bcolB)
    endif
    NEXT
       
    endif
    
    
    return
    
    

    Bonjour,

    Cet indicateur « Power Channel » vient de la bibliothèque…

    robertogozzi, Ball and Iván González thanked this post
    #259897 quote
    Ball
    Participant
    New

    Un grand merci pour la réponse et votre rapidité.

    Est-il possible de faire un screener à partir de cet indicateur ?

    #259906 quote
    Iván González
    Moderator
    Master

    voici

    // -----------------------------------------------
    // SRC_Support and Resistance Power Channel
    //version = 0
    //09.10.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    // -----------------------------------------------
    // INPUTS
    // -----------------------------------------------
    //length = 130
    // -----------------------------------------------
    // CALCULATION SUPPORT AND RESISTANCE AREA
    // -----------------------------------------------
    // ATR
    atr = AverageTrueRange[200] * 0.5
    // HIGHEST AND LOWEST PRICE
    maxVal = HIGHEST[length](high)
    minVal = LOWEST[length](low)
    
    topOfSupport = minVal + atr
    bottomOfSupport = minVal - atr
    topOfResistance = maxVal + atr
    bottomOfResistance = maxVal - atr
    
    setupResistance = high>bottomOfResistance and low<topOfResistance
    setupSupport = low<topOfSupport and high>bottomOfSupport
    // -----------------------------------------------
    // BUY AND SELL POWER
    // -----------------------------------------------
    buyPower = 0
    sellPower = 0
    
    FOR i = 0 TO length - 1 DO
       IF close[i] > open[i] THEN
          buyPower = buyPower + 1
       ELSIF close[i] < open[i] THEN
          sellPower = sellPower + 1
       ENDIF
    NEXT
    // -----------------------------------------------
    // CAPITALIZATION FILTER
    // -----------------------------------------------
    capital = average[20](close*volume)
    millon = 1000000
    // -----------------------------------------------
    screener[(setupSupport or setupResistance) and capital>minCap*millon](setupResistance as "Res=1/Sup=0",buyPower as "BuyPower",sellPower as "SellPower")
    


    #259979 quote
    Ball
    Participant
    New

    Le code ne fonctionne pas.

    1ère Erreur : définir la variable lenght ce que j’ai fait (j’ai supprimé // devant length). Erreur résolue.

    J’ai ensuite une nouvelle erreur “veuillez définir la variable suivante” sans aucune indication de celle dont il s’agit

    #259981 quote
    JS
    Participant
    Veteran

    Le screener fonctionne lorsque vous modifiez les paramètres ci-dessous sous « INPUTS »…

    Length = 130

    minCap = 100

    Le nombre 100 est ensuite multiplié plus loin dans le code par 1 million, ce qui signifie que 100 correspond à 100 000 000 (vous pouvez ajuster ce nombre (100) selon vos besoins)…

    Iván González and Bernard13 thanked this post
    Scherm­afbeelding-2026-04-08-om-22.16.34.png Scherm­afbeelding-2026-04-08-om-22.16.34.png
    #259982 quote
    Ball
    Participant
    New

    Parfait ! ça marche nickel.

    Un grand merci.

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

Support and Resistance Power Channel


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Ball @ball Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by Ball
1 week ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 04/04/2026
Status: Active
Attachments: 1 files
Logo Logo
Loading...