Hola:
Se podría hacer del Screener del indicador que detallo a continuación.
Gracias.
https://www.prorealcode.com/topic/formaciones-en-expansion/
Sería así:
period=9
leftbars=period
rightbars=period//max(1,floor(period/2))
src1 = low
src2 = high
//---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
//Up Trendline
if islastbarupdate then
crossedline=0
setupup=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]
x2=$Px[i-1]
y2=$Py[i-1]
for j=$Px[i-1]+1 to barindex do
x3=j
y3=y1+(x3-x1)*$slope[i-1]
if close[barindex-j]>y3 then
crossedline=1
break
endif
next
x = barindex
y = y1+(x-x1)*(y2-y1)/(x2-x1)
if crossedline=0 and high>y and low<y then
setupup=1
endif
endif
endif
next
endif
//Down Trendline
if islastbarupdate then
crossedline=0
setupdn=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]
x2=$Px[i-1]
y2=$Py[i-1]
for j=$Px[i-1]+1 to barindex do
x3=j
y3=y1+(x3-x1)*$slope[i-1]
if close[barindex-j]>y3 then
crossedline=1
break
endif
next
x = barindex
y = y1+(x-x1)*(y2-y1)/(x2-x1)
if crossedline=0 and high>y and low<y then
setupdn=-1
endif
endif
endif
next
endif
screener[setupup or setupdn]
Te saldrán muy pocos valores porque le estás pidiendo valores que van contrapendiente.
Gracias Ivan, veo que tienes razón pues cargue el Screener y no me devolvió nada. Seguiré probando para ver que es lo que hace, pues en los gráficos compruebo que si marca los segmentos de unión de 2 o más mínimos.
Entendiendo que si el gráfico marca el segmento, en algún momento el Screener nos tendrá que devolver algo.
.