Esto sería una posibilidad. Se busca el cruce al alza del punto pivote máximo (ver captura de pantalla)
prd = 5
////////pivothigh
ph1 = high < high[prd]
ph2 = highest[prd](high) < high[prd]
ph3 = high[prd] > highest[prd](high)[prd+1]
if ph1 and ph2 and ph3 then
$pivot[n+1] = high[prd]
$pivotx[n+1] = barindex[prd]
$pivotType[n+1] = 1
n=n+1
//drawpoint(barindex[prd],high[prd],2)coloured("blue",140)
endif
////////pivotlow
pl1 = low > low[prd]
pl2 = lowest[prd](low) > low[prd]
pl3 = low[prd] < lowest[prd](low)[prd+1]
if pl1 and pl2 and pl3 then
$pivot[n+1] = low[prd]
$pivotx[n+1] = barindex[prd]
$pivotType[n+1] = -1
n=n+1
//drawpoint(barindex[prd],low[prd],2)coloured("red",140)
endif
if n>2 then
if $pivot[n]<$pivot[max(0,n-1)] and $pivot[max(0,n-1)]>$pivot[max(0,n-2)] and $pivotType[n]=-1 and $pivotType[max(0,n-1)]=1 and $pivotType[max(0,n-2)] then
H1=$pivot[n-1]-$pivot[n-2]
H2=$pivot[n-1]-$pivot[n]
if H2<H1*0.764 and H2>H1*0.382 then
check=1
checklevel=$pivot[n-1]
checkleveldw=$pivot[n]
//checkx=$pivotx[n-1]
else
check=0
endif
endif
if check=1 then
//drawsegment(checkx,checklevel,barindex,checklevel)
if high crosses over checklevel then
//drawarrowup(barindex,low)
//drawsegment(checkx,checklevel,barindex,checklevel)
check=0
elsif n<>n[1] then
check=0
endif
endif
endif
if check=1 and high crosses over checklevel and low>checkleveldw then
setup=1
else
setup=0
endif
screener[setup]
Otra opción, para que aparezcan más valores es controlar aquellos que aún no han roto el nivel.
prd = 5
////////pivothigh
ph1 = high < high[prd]
ph2 = highest[prd](high) < high[prd]
ph3 = high[prd] > highest[prd](high)[prd+1]
if ph1 and ph2 and ph3 then
$pivot[n+1] = high[prd]
$pivotx[n+1] = barindex[prd]
$pivotType[n+1] = 1
n=n+1
//drawpoint(barindex[prd],high[prd],2)coloured("blue",140)
endif
////////pivotlow
pl1 = low > low[prd]
pl2 = lowest[prd](low) > low[prd]
pl3 = low[prd] < lowest[prd](low)[prd+1]
if pl1 and pl2 and pl3 then
$pivot[n+1] = low[prd]
$pivotx[n+1] = barindex[prd]
$pivotType[n+1] = -1
n=n+1
//drawpoint(barindex[prd],low[prd],2)coloured("red",140)
endif
if n>2 then
if $pivot[n]<$pivot[max(0,n-1)] and $pivot[max(0,n-1)]>$pivot[max(0,n-2)] and $pivotType[n]=-1 and $pivotType[max(0,n-1)]=1 and $pivotType[max(0,n-2)] then
H1=$pivot[n-1]-$pivot[n-2]
H2=$pivot[n-1]-$pivot[n]
if H2<H1*0.764 and H2>H1*0.382 then
check=1
checklevel=$pivot[n-1]
checkleveldw=$pivot[n]
//checkx=$pivotx[n-1]
else
check=0
endif
endif
if check=1 then
//drawsegment(checkx,checklevel,barindex,checklevel)
if high crosses over checklevel then
//drawarrowup(barindex,low)
//drawsegment(checkx,checklevel,barindex,checklevel)
check=0
elsif n<>n[1] then
check=0
endif
endif
endif
if check=1 and high < checklevel and low>checkleveldw then
setup=1
else
setup=0
endif
screener[setup]