This indicator is from jose Silva {Trendline - adjustable} {©Copyright 2003 Jose Silva} pds:= Input("average trend length periods",2,252,21); pr:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 MP=6",1,6,4); display:=Input("Trend line = 1, Trend points = 2",1,2,1); {define events} pr:=If(pr=1,O,If(pr=2,H,If(pr=3,L,If(pr=5,V, If(pr=6,MP(),C))))); price1:=pr; price2:=pr; time1:=price1>Ref(HHV(price1,pds),-1); time2:=price2=t2pds,time1,time2); x2:=If(t1pds>=t2pds,time2,time1); y1:=If(t1pds>=t2pds,price1,price2); y2:=If(t1pds>=t2pds,price2,price1); {fix coordinates} y1:=ValueWhen(1,x1,y1); y2:=LastValue(ValueWhen(1,x2,y2)); b1:=LastValue(BarsSince(x1)); b2:=LastValue(BarsSince(x2)); plot:=y1+BarsSince(x1)*(y2-y1)/(b1-b2); If(display=1,plot,Time1+Time2)