Iván
He visto este indicador de [QuantVue] recientemente y creo que estas formaciones en expansión que ofrece pueden ser interesantes en el Trading. Se podría hacer la conversión del mismo,
https://www.tradingview.com/script/PghpY09l-Broadening-Formations-QuantVue/
Gracias,
Buenas, aquí tienes:
//--------------------------------------------------//
//PRC_Broadening Formations Lines
//version = 0
//11.02.2025
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//--------------------------------------------------//
// Inputs
//--------------------------------------------------//
period=9 // Pivot Length
pivottype=1 // 1 means wicks // 0 means Body
MaxDist=40 // Max distance from line (%)
showpivots=0 //Show Pivot points
//--------------------------------------------------//
// Pivots High and Low
//--------------------------------------------------//
leftbars=period
rightbars=period//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
if $Type[z]=-1 and src1[rightbars]<$Py[z] then
$Py[z]=src1[rightbars]
$Px[z]=barindex[rightbars]
else
$Py[z+1]=src1[rightbars]
$Px[z+1]=barindex[rightbars]
$Type[z+1]=-1
z=z+1
endif
//y=(x-x1)*slope+y1
if $Py[z]<$Py[max(0,z-2)] then
$slope[z]=($Py[z]-$Py[max(0,z-2)])/($Px[z]-$Px[max(0,z-2)])
endif
endif
//---Pivots High
if src2 < src2[rightbars] and highest[rightbars](src2)<src2[rightbars] and src2[rightbars]>highest[leftbars](src2)[rightbars+1] then
if $Type[z]=1 and src2[rightbars]>$Py[z] then
$Py[z]=src2[rightbars]
$Px[z]=barindex[rightbars]
else
$Py[z+1]=src2[rightbars]
$Px[z+1]=barindex[rightbars]
$Type[z+1]=1
z=z+1
endif
//y=(x-x1)*slope+y1
if $Py[z]>$Py[max(0,z-2)] then
$slope[z]=($Py[z]-$Py[max(0,z-2)])/($Px[z]-$Px[max(0,z-2)])
endif
endif
if islastbarupdate and showpivots then
for i=z downto 3 do
drawpoint($Px[i],$Py[i],4)coloured("blue",50)
next
endif
//--------------------------------------------------//
// Draw trendlines
//--------------------------------------------------//
//Up Trendline
if islastbarupdate then
crossedline=0
for i=z downto 4 do
if $Type[i-1]=1 and $Type[i-3]=1 then
if $Py[i-1]>$Py[i-3] then
x1=$Px[i-3]
y1=$Py[i-3]
for j=$Px[i-1]+1 to barindex do
x2=j
y2=y1+(x2-x1)*$slope[i-1]
if close[barindex-j]>y2 then
drawsegment(x1,y1,x2,y2)coloured("orange")style(dottedline2,2)
crossedline=1
break
endif
next
if crossedline=0 and (y2/close-1)*100<MaxDist then
drawsegment(x1,y1,x2,y2)coloured("red")style(line,2)
endif
endif
endif
next
endif
//Down Trendline
if islastbarupdate then
crossedline=0
for i=z downto 4 do
if $Type[i-1]=-1 and $Type[i-3]=-1 then
if $Py[i-1]<$Py[i-3] then
x1=$Px[i-3]
y1=$Py[i-3]
for j=$Px[i-1]+1 to barindex do
x2=j
y2=y1+(x2-x1)*$slope[i-1]
if close[barindex-j]<y2 then
drawsegment(x1,y1,x2,y2)coloured("orange")style(dottedline2,2)
crossedline=1
break
endif
next
if crossedline=0 and (close/y2-1)*100<MaxDist then
drawsegment(x1,y1,x2,y2)coloured("green")style(line,2)
endif
endif
endif
next
endif
return
Hola
Es una maravilla todo lo que realizas. y tengo que felicitarte continuamente, no obstante observo en algunos gráficos un exceso de señales, creo que si pongo la ultima señal solamente
para no cargar demasiado el gráfico tanto en la parte superior como en la inferior ganaría el gráfico. Cuidado es una apreciación por mi parte.
Hola
No hago mas que darte trabajo, se podría realizar un Screener de este indicador, indicando 1 ó 2 en suelos/techos.
Gracias,