//-------------------------------------------------//
//PRC WEDGE MAKER
//version = 0
//24.01.25
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-------------------------------------------------//
// Inputs
//-------------------------------------------------//
// Pivots length
lenght1=20
lenght2=20
// Reference to start draw
astart=2
aend=0
bstart=3
bend=0
// Source to pivot calculation
usesrc=0
if usesrc then
src1 = low
src2 = high
else
src1 = close
src2 = close
endif
//-------------------------------------------------//
// Calculate Pivots
//-------------------------------------------------//
// Pivot High
ph1 = src2 < src2[lenght1]
ph2 = highest[lenght1](src2) < src2[lenght1]
ph3 = src2[lenght1] > highest[lenght1](src2)[lenght1+1]
if ph1 and ph2 and ph3 then
$pH[t+1] = src2[lenght1]
$pHx[t+1] = barindex[lenght1]
t=t+1
endif
// Pivot Low
pl1 = src1 > src1[lenght2]
pl2 = lowest[lenght2](src1) > src1[lenght2]
pl3 = src1[lenght2] < lowest[lenght2](src1)[lenght2+1]
if pl1 and pl2 and pl3 then
$pL[z+1] = src1[lenght2]
$pLx[z+1] = barindex[lenght2]
z=z+1
endif
//-------------------------------------------------//
// Calculate Trend Lines
//-------------------------------------------------//
if islastbarupdate then
if t>astart then
ux1=$phx[t-aend]
uy1=$ph[t-aend]
ux2=$phx[t-astart]
uy2=$ph[t-astart]
//(x-x1)/(x2-x1) = (y-y1)/(y2-y1)
ux=barindex+20
uy=(ux-ux1)/(ux2-ux1)*(uy2-uy1)+uy1
drawsegment(ux2,uy2,ux,uy)coloured("green")
endif
if z>bstart then
dx1=$plx[z-bend]
dy1=$pl[z-bend]
dx2=$plx[z-bstart]
dy2=$pl[z-bstart]
//(x-x1)/(x2-x1) = (y-y1)/(y2-y1)
dx=barindex+20
dy=(dx-dx1)/(dx2-dx1)*(dy2-dy1)+dy1
drawsegment(dx,dy,dx2,dy2)coloured("red")
endif
endif
return