Bonjour,
j’utilise ce code pour récupérer la valeur mediane entre le plus haut et le plus bas d’une période donnée
defparam DRAWONLASTBARONLY=true
decal=1 // pour décaler l'affichage au-dessus et en-dessous des mèches
start = 220000
end = 080000
tc = time>start or time<=end
if tc then
if not tc[1] then
hh=high
ll=low
endif
hh=max(high,hh)
ll=min(low,ll)
if hh<>hh[1] then
barhh=barindex
endif
if ll<>ll[1] then
barll=barindex
endif
endif
DRAWTEXT("#hh#", barhh, hh+decal*pipsize)
DRAWTEXT("#ll#", barll, ll-decal*pipsize)
phpb = (hh + ll) / 2
if time = 090100 THEN
bar = barindex
ENDIF
if barhh < barll THEN
r = 80
g = 210
b = 80
ELSE
r = 220
g = 110
b = 110
ENDIF
DRAWTEXT("PHPB",barindex-2,phpb+1/pipsize,SansSerif,Standard,12) Coloured(r,g,b)
DRAWSEGMENT(bar,phpb,barindex,phpb) COLOURED(r,g,b) STYLE(line,4)
return
Existe-il un moyen de conserver cette ligne pour chacune des journées affichées sur l’historique un peu comme un point pivot ?
Merci beaucoup de votre aide
Bonne journée.
Avec cette version du code, on enregistre la valeur actuelle dans la colonne i du tableau $phpb
defparam DRAWONLASTBARONLY=true
decal=1 // pour décaler l'affichage au-dessus et en-dessous des mèches
start = 220000
end = 080000
tc = time>start or time<=end
if tc then
if not tc[1] then
hh=high
ll=low
i=i+1
endif
hh=max(high,hh)
ll=min(low,ll)
if hh<>hh[1] then
barhh=barindex
endif
if ll<>ll[1] then
barll=barindex
endif
endif
DRAWTEXT("#hh#", barhh, hh+decal*pipsize)
DRAWTEXT("#ll#", barll, ll-decal*pipsize)
$phpb[i] = (hh + ll) / 2
if time = 090100 THEN
bar = barindex
ENDIF
if barhh < barll THEN
r = 80
g = 210
b = 80
ELSE
r = 220
g = 110
b = 110
ENDIF
DRAWTEXT("PHPB",barindex-2,$phpb[i]+1/pipsize,SansSerif,Standard,12) Coloured(r,g,b)
DRAWSEGMENT(bar,$phpb[i],barindex,$phpb[i]) COLOURED(r,g,b) STYLE(line,4)
return
A voir ensuite comment tu comptes utiliser toutes ces anciennes valeurs. Pour cela il faudra explorer toutes les colonnes de la variable.
Merci beaucoup pour cette réponse.
En fait je voudrais pouvoir afficher chaque jour (même les jours précédents) une ligne représentant cette valeur, un peu comme un point pivot journalier.
et voilà, on faite une boucle dans les valeurs du tableau depuis la barre actuelle et on trace chaque valeur du tableau. J’ai du ajouter un tableau pour stocker la BARINDEX de quand comment la session:
defparam DRAWONLASTBARONLY=true
decal=1 // pour décaler l'affichage au-dessus et en-dessous des mèches
start = 220000
end = 080000
tc = time>start or time<=end
if tc then
if not tc[1] then
hh=high
ll=low
i=i+1
$startbar[i]=barindex
endif
hh=max(high,hh)
ll=min(low,ll)
if hh<>hh[1] then
barhh=barindex
endif
if ll<>ll[1] then
barll=barindex
endif
endif
DRAWTEXT("#hh#", barhh, hh+decal*pipsize)
DRAWTEXT("#ll#", barll, ll-decal*pipsize)
$phpb[i] = (hh + ll) / 2
if time = 090100 THEN
bar = barindex
ENDIF
if barhh < barll THEN
r = 80
g = 210
b = 80
ELSE
r = 220
g = 110
b = 110
ENDIF
if islastbarupdate then
for j=0 to i do
DRAWTEXT("PHPB",$startbar[j]-2,$phpb[j]+1/pipsize,SansSerif,Standard,12) Coloured(r,g,b)
DRAWSEGMENT($startbar[j],$phpb[j],$startbar[j+1],$phpb[j]) COLOURED(r,g,b) STYLE(line,4)
next
endif
return
Bonjour,
Merci beaucoup pour votre réponse.
Cela fonctionne très bien.
J’ai juste un petit soucis car la ligne ne s’affiche pas pour la session du jour, j’ai juste le texte PHPB.
Est-il possible aussi de mettre le texte PHPB à droite de la ligne plutôt quà gauche ?
Je vous ai mis une capture.
Encore merci.
Ci-dessous le code corrigé pour afficher la ligne de la session en cours et avec le texte situé à droite de chaque ligne:
defparam DRAWONLASTBARONLY=true
decal=1 // pour décaler l'affichage au-dessus et en-dessous des mèches
start = 220000
end = 080000
tc = time>start or time<=end
if tc then
if not tc[1] then
hh=high
ll=low
i=i+1
$startbar[i]=barindex
endif
hh=max(high,hh)
ll=min(low,ll)
if hh<>hh[1] then
barhh=barindex
endif
if ll<>ll[1] then
barll=barindex
endif
endif
DRAWTEXT("#hh#", barhh, hh+decal*pipsize)
DRAWTEXT("#ll#", barll, ll-decal*pipsize)
$phpb[i] = (hh + ll) / 2
if time = 090100 THEN
bar = barindex
ENDIF
if barhh < barll THEN
r = 80
g = 210
b = 80
ELSE
r = 220
g = 110
b = 110
ENDIF
if islastbarupdate then
for j=i downto 0 do
if j=i then
DRAWSEGMENT($startbar[j],$phpb[j],barindex,$phpb[j]) COLOURED(r,g,b) STYLE(line,4)
DRAWTEXT("PHPB",barindex,$phpb[j]+1/pipsize,SansSerif,Standard,12) Coloured(r,g,b)
else
DRAWSEGMENT($startbar[j],$phpb[j],$startbar[j+1],$phpb[j]) COLOURED(r,g,b) STYLE(line,4)
DRAWTEXT("PHPB",$startbar[j+1],$phpb[j]+1/pipsize,SansSerif,Standard,12) Coloured(r,g,b)
endif
next
endif
return