Wedge Maker

Category: Indicators By: Iván González Created: March 18, 2026, 11:04 AM
March 18, 2026, 11:04 AM
Indicators
0 Comments

Wedges are one of the most reliable chart patterns in technical analysis. They form when price action converges between two sloping trendlines, signaling a potential breakout. Identifying them manually is subjective and time-consuming — this indicator automates the process by detecting pivot points and drawing the corresponding trendlines dynamically.

 

How it works

 

The indicator operates in three stages:

 

Pivot detection — It scans the chart for significant pivot highs and pivot lows using a lookback window defined by the user. A valid pivot high occurs when the source value at the lookback offset is higher than all surrounding values within the specified length. The same logic applies in reverse for pivot lows. Each detected pivot is stored along with its bar index for later use.

 

Trendline calculation — Once enough pivots are collected, the indicator selects two reference points for the upper line (from pivot highs) and two for the lower line (from pivot lows). The user controls which pivots to use through the astart/aend and bstart/bend parameters, allowing flexibility in how far back the trendlines reach.

 

Projection — Using linear interpolation between the two reference points, each trendline is extended 20 bars into the future. The formula (x - x1) / (x2 - x1) * (y2 - y1) + y1 maps the price level at any bar position along the line. All drawing is performed only on the last bar update to keep the chart clean and avoid ghost lines.

 

Parameters

 

  • lenght1 — Lookback period for pivot low detection. Higher values produce fewer, more significant pivots. Default: 20.
  • lenght2 — Lookback period for pivot high detection. Default: 20.
  • astart — Index offset for the older pivot high reference point. Default: 2.
  • aend — Index offset for the most recent pivot high reference point. Default: 0 (latest pivot).
  • bstart — Index offset for the older pivot low reference point. Default: 3.
  • bend — Index offset for the most recent pivot low reference point. Default: 0 (latest pivot).
  • usesrc — Source selection. Set to 1 to use high/low as pivot sources, or 0 to use close for both. Default: 0.

Code

 

//-------------------------------------------------//
// PRC WEDGE MAKER 
// Adapted from PineScript [veryfid]
// version = 0
// 24.01.2025
// Iván González @ www.prorealcode.com
// Sharing ProRealTime knowledge
//-------------------------------------------------//
defparam drawonlastbaronly=true
//-------------------------------------------------//
// 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

Download
Filename: PRC_WEDGE-MAKER.itf
Downloads: 31
Iván González Master
As an architect of digital worlds, my own description remains a mystery. Think of me as an undeclared variable, existing somewhere in the code.
Author’s Profile

Comments

Logo Logo
Loading...