//PRC_triangle Wedge pattern | screener
//12.09.2016
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// modified by Yannick v4 31.10.2017 avec affichage des buystop et sellstop level
//fractals
cp = 1//4 //lookback
//Detection High
if high[cp] >= highest[(cp)*2+1](high) then
LLH = 1
else
LLH = 0
endif
//Value of last High
if LLH = 1 then
High1 = High2[1]
High1bar = High2bar[1]
High2 = high[cp]
High2bar = barindex[cp]
endif
//Detection Low
if low[cp] <= lowest[(cp)*2+1](low) then
LLL = -1
else
LLL = 0
endif
//Value of last Low
if LLL = -1 then
Low1 = Low2[1]
Low1bar = Low2bar[1]
Low2 = low[cp]
Low2bar = barindex[cp]
endif
triangle = High1>High2 and Low1<Low2 and abs(High1-Low1)> abs(High2-Low2) //triangle conditions 1+2 contraction Low increasing and High decreasing
oscillationH1L1H2L2= High1bar< Low1bar and Low1bar< High2bar and High2bar<Low2bar //triangle condition 3 oscillation
oscillationL1H1L2H2= Low1bar<High1bar and High1bar<Low2bar and Low2bar< High2bar //triangle condition 3 oscillation
triangleamplitude=abs(High1-Low1)< 2* abs(High2-Low2)
//triangleamplitude =1
//Triangle display and H1L1H2L2
if triangle and triangleamplitude and oscillationH1L1H2L2 or triangle and triangleamplitude and oscillationL1H1L2H2 then
//DRAWSEGMENT(Low1bar,Low1,Low2bar,Low2,barindex+5)
//DRAWSEGMENT(High1bar,High1,High2bar,High2,barindex+5)
startbar=barindex
endif
//calculation of upperline equation
aH=(High2-High1)/(High2bar-High1bar)
//calculation of lowerline equation
aL=(Low2-Low1)/(Low2bar-Low1bar)
signal=0
//intercept
upperline = high2+ah*(barindex-high2bar)
if close crosses over upperline and upperline>0 and barindex-startbar<=5 then
signal=1
//drawarrowup(barindex,low-averagetruerange[14]/2) coloured(0,255,0)
endif
//drawpoint(barindex,high2+ah*(barindex-high2bar))
lowerline = low2-al*(barindex-low2bar)
if close crosses under lowerline and lowerline>0 and barindex-startbar<=5 then
signal=-1
//drawarrowdown(barindex,high+averagetruerange[14]/2) coloured(255,0,0)
endif
screener[signal<>0]