Après une analyse plus approfondie 🙂 voir mon image jointe pour commencer !
BarsSince ne répond pas à la question “où se trouve l’extrême dans ma fenêtre de 60 bougies ?”, mais à “à quand remonte la dernière fois où ce prix précis est apparu”.
Du coup, quand le nouveau Lowest des 60 dernières bougies est égal à un creux plus ancien, BarsSince peut retourner 93 (ou tout autre nombre > 60), alors que l’extrême de la fenêtre courante est… dans la fenêtre !
Ton premier code est donc correct pour dater la dernière occurrence d’un prix, mais pas adapté à ce que tu veux faire ici (pointer l’extrême dans la période).
Pour ça, il faut utiliser HighestBars / LowestBars qui renvoient l’offset (0…Période-1) de l’extrême à l’intérieur de la fenêtre.
Voir: https://www.prorealcode.com/documentation/highestbars/
Selon moi, voici le code adapté :
DefParam DrawOnLastBarOnly = true
Periode = 60
if barindex>periode then
// +HAUT sur la période
hautBars = HighestBars[Periode](High) // offset de l'extrême dans la fenêtre (0..Periode-1)
hautPrix = High[hautBars]
if hautBars >= 0 then
DrawText("#HAUTprix#", BarIndex[hautBars], hautPrix+3) Coloured(255,0,0)
DrawText("#hautBars#", BarIndex[hautBars], hautPrix+2) Coloured(255,0,0)
DrawArrowDown(BarIndex[hautBars], hautPrix+1) Coloured(255,0,0)
endif
// +BAS sur la période
basBars = LowestBars[Periode](Low) // offset de l'extrême dans la fenêtre (0..Periode-1)
basPrix = Low[basBars]
if basBars >= 0 then
DrawText("#BASprix#", BarIndex[basBars], basPrix-3) Coloured(0,128,0)
DrawText("#basBars#", BarIndex[basBars], basPrix-2) Coloured(0,128,0)
DrawArrowUp(BarIndex[basBars], basPrix-1) Coloured(0,128,0)
endif
endif
RETURN