Ciao Ivan, ottimo lavoro. Mi piacerebbe provare questo indicatore in un sistema automatizzato, ma non capisco cosa devo fare per attivare un segnale di ingresso con le frecce rosse o verdi.
Grazie
//--------------------------------------------------//
//PRC_TrendLine BreakOuts by chartprime
//version = 0
//27.11.2024
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//--------------------------------------------------//
// Inputs
//--------------------------------------------------//
period=9
pivottype=1 // 1 means wicks // 0 means Body
showtrendUP=1 //Boolean
showtrendDN=1 //Boolean
//--------------------------------------------------//
// Pivots High and Low
//--------------------------------------------------//
leftbars=period
rightbars=max(1,floor(period/2))
if pivottype then
src1 = low
src2 = high
else
src1 = min(open,close)
src2 = max(open,close)
endif
//---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]
z=z+1
//y=(x-x1)*slope+y1
if $PLy[z]>$PLy[z-1] then
$slopeL[z]=($PLy[z]-$PLy[z-1])/($PLx[z]-$PLx[z-1])
endif
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]
t=t+1
//y=(x-x1)*slope+y1
if $PHy[t]<$PHy[t-1] then
$slope[t]=($PHy[t]-$PHy[t-1])/($PHx[t]-$PHx[t-1])
endif
endif
//--------------------------------------------------//
//Volatility for TP and SL
//--------------------------------------------------//
Zband=min(averagetruerange[30](close)*0.3,close*(0.3/100))[20]/2
//--------------------------------------------------//
// Draw trendlines and trading signals
//--------------------------------------------------//
//Trendline and Long positions
if islastbarupdate and showtrendUP then
for i=t downto 4 do
if $PHy[i-1]<$PHy[i-2] then
x1=$PHx[i-2]
y1=$PHy[i-2]
for j=$PHx[i-1]+1 to barindex do
x2=j
y2=y1+(x2-x1)*$slope[i-1]
if close[barindex-j]>y2 then
tp=high[barindex-j]+(Zband[barindex-j]*20)
sl=low[barindex-j]-(Zband[barindex-j]*20)
break
endif
next
for k=x2+1 to barindex do
if high[barindex-k]>=tp then
x3=k
sellprice=max(tp,open[barindex-k])
win=1
break
elsif low[barindex-k]<=sl then
x3=k
sellprice=min(sl,open[barindex-k])
win=0
break
else
x3=barindex
endif
next
if x2<$PHx[i] then
drawsegment(x1,y1,x2,y2)coloured("darkgreen")
drawtext("▲",x2,y2-0.25*tr[1])coloured("green")
drawsegment(x2,tp,x3,tp)style(dottedline)coloured("green")
drawsegment(x2,sl,x3,sl)style(dottedline)coloured("darkred")
drawsegment(x2,y2,x2,tp)style(dottedline4,1)coloured("green")
drawsegment(x2,y2,x2,sl)style(dottedline4,1)coloured("green")
if x3<>barindex then
drawpoint(x3,sellprice,1)coloured("orange")
drawtext("✖",x3,sellprice+0.25*tr[1])coloured("green")
endif
endif
endif
next
endif
//---TrendLine and Short positions
if islastbarupdate and showtrendDN then
for i=z downto 4 do
if $PLy[i-1]>$PLy[i-2] then
x1=$PLx[i-2]
y1=$PLy[i-2]
for j=$PLx[i-1]+1 to barindex do
x2=j
y2=y1+(x2-x1)*$slopeL[i-1]
if close[barindex-j]<y2 then
sl=high[barindex-j]+(Zband[barindex-j]*20)
tp=low[barindex-j]-(Zband[barindex-j]*20)
break
endif
next
for k=x2+1 to barindex do
if high[barindex-k]>=sl then
x3=k
sellprice=max(sl,open[barindex-k])
win=0
break
elsif low[barindex-k]<=tp then
x3=k
sellprice=min(tp,open[barindex-k])
win=1
break
else
x3=barindex
endif
next
if x2<$PLx[i] then
drawsegment(x1,y1,x2,y2)coloured("darkred")
drawtext("▼",x2,y2+0.50*tr[1])coloured("darkred")
drawsegment(x2,tp,x3,tp)style(dottedline)coloured("green")
drawsegment(x2,sl,x3,sl)style(dottedline)coloured("darkred")
drawsegment(x2,y2,x2,tp)style(dottedline4,1)coloured("green")
drawsegment(x2,y2,x2,sl)style(dottedline4,1)coloured("green")
if x3<>barindex then
drawpoint(x3,sellprice,1)coloured("orange")
drawtext("✖",x3,sellprice+0.25*tr[1])coloured("darkred")
endif
endif
endif
next
endif
//--------------------------------------------------//
return