Translate from TradingView Indicator:Trendline Pivots [QuantVue]

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #237877 quote
    roccafragius
    Participant
    Junior

    I see in TV a very useful Indicator, please find below the description from TV:
    Trendline Pivots

    The Trend Line Pivot Indicator works by automatically drawing and recognizing downward trendlines originating from and connecting pivot highs or upward trendlines originating from and connecting pivot lows.

    These trendlines serve as reference points of potential resistance and support within the market.

    Once identified, the trend line will continue to be drawn and progress with price until one of two conditions is met: either the price closes(default setting) above or below the trend line, or the line reaches a user-defined maximum length.

    If the price closes(default setting) above a down trend line or below an up trend line, an “x” is displayed, indicating the resistance or support has been broken. At the same time, the trend line transforms into a dashed format, enabling clear differentiation from active non-breached trend lines.

    This indicator is fully customizable from line colors, pivot length, the number lines you wish to see on your chart and works on any time frame and any market.

    #237888 quote
    robertogozzi
    Moderator
    Master

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums. Thanks 🙂

    I moved the topic from the Italian forum.

    #238012 quote
    Iván González
    Moderator
    Master

    Here you have the traslation:

    defparam drawonlastbaronly=true
    //-----------------------------------------------//
    //PRC_TrendLine pivots
    //version = 0
    //25.09.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-----------------------------------------------//
    //-----Inputs------------------------------------//
    //-----------------------------------------------//
    maxLines=4
    pivLen=9
    //-----------------------------------------------//
    //-----Pivots High and Low-----------------------//
    //-----------------------------------------------//
    src1 = low
    src2 = high
    leftbars=pivLen
    rightbars=pivLen
    //---Pivots low
    if src1 > src1[rightbars] and lowest[rightbars](src1) > src1[rightbars] and src1[rightbars] < lowest[leftbars](src1)[rightbars+1] then
    $ply[z+1] = src1[rightbars]
    $plx[z+1] = barindex[rightbars]
    //drawpoint(barindex[rightbars],src1[rightbars],2)coloured("red",80)
    $crossdw[z+1]=0
    z = z + 1
    endif
    //---Pivots high
    if src2 < src2[rightbars] and highest[rightbars](src2)<src2[rightbars] and src2[rightbars]>highest[leftbars](src2)[rightbars+1] then
    $phy[t+1]=src2[rightbars]
    $phx[t+1]=barindex[rightbars]
    //drawpoint(barindex[rightbars],src2[rightbars],2)coloured("blue",80)
    $crossup[t+1]=0
    t=t+1
    endif
    //-----------------------------------------------//
    //-----Line definition---------------------------//
    //-----------------------------------------------//
    //(x-x1)/(x2-x1) = (y-y1)/(y2-y1)
    //x = barindex
    //y = y1+(barindex-x1)*(y2-y1)/(x2-x1)
    
    if islastbarupdate then
    //---Pivots low line
    for i=z-maxLines*2 to z do
    $y2[i] = $ply[i]
    $x2[i] = $plx[i]
    $y1[i] = $ply[max(i-1,0)]
    $x1[i] = $plx[max(i-1,0)]
    for j=$plx[i] downto 0 do
    $xl[i] = barindex[j]
    $yl[i] = $y1[i]+(barindex[j]-$x1[i])*($y2[i]-$y1[i])/($x2[i]-$x1[i])
    if $xl[i]>$x2[i] and $y2[i]>$y1[i] and low[j] < $yl[i] then
    $crossdw[i]=1
    drawsegment($x1[i],$y1[i],barindex[j],$yl[i])style(dottedline,2)coloured("blue")
    break
    elsif $xl[i]>$x2[i] and $y2[i]>$y1[i] and $crossdw[i]=0 then
    drawsegment($x1[i],$y1[i],barindex,$ply[max(i-1,0)]+(barindex-$plx[max(i-1,0)])*($ply[i]-$ply[max(i-1,0)])/($plx[i]-$plx[max(i-1,0)]))style(line,2)coloured("green")
    endif
    next
    next
    //---Pivots high line
    for k=t-maxLines*2 to t do
    $y22[k] = $phy[k]
    $x22[k] = $phx[k]
    $y11[k] = $phy[max(k-1,0)]
    $x11[k] = $phx[max(k-1,0)]
    for n=$phx[k] downto 0 do
    $xh[k] = barindex[n]
    $yh[k] = $y11[k]+(barindex[n]-$x11[k])*($y22[k]-$y11[k])/($x22[k]-$x11[k])
    if $xh[k]>$x22[k] and $y22[k]<$y11[k] and high[n] > $yh[k] then
    $crossup[k]=1
    drawsegment($x11[k],$y11[k],barindex[n],$yh[k])style(dottedline,2)coloured("orange")
    break
    elsif $xh[k]>$x22[k] and $y22[k]<$y11[k] and $crossup[k]=0 then
    drawsegment($x11[k],$y11[k],barindex,$y11[k]+(barindex-$x11[k])*($y22[k]-$y11[k])/($x22[k]-$x11[k]))style(line,2)coloured("red")
    endif
    next
    next
    endif
    //-----------------------------------------------//
    return
    #238034 quote
    Msport71
    Participant
    Junior

    Hi,

     

    very interesting.

    It would be possible to manage the look back ? (actualluy the indicator seems to work in a range of about 300 bars)

    Thanks

    #238041 quote
    Iván González
    Moderator
    Master

    Just change value of maxLines=4.

    Msport71 thanked this post
    #238072 quote
    roccafragius
    Participant
    Junior

    Thank you so much Ivan!!!

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

Translate from TradingView Indicator:Trendline Pivots [QuantVue]


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by roccafragius
1 year, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/20/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...