je suis tombé sur un bug particulièrement pénible, semble t'il, sur prt. En effet je pense que le système de variable à quelques défauts, c'est comme si la variable pointais sur une ancienne valeur.
Comme vous pourrez le voir ci dessous ( j'ai fait le bourrin ), j'ai simplement identifié 2 indices bougies "plus haut" sur une période de 21. Si à la fin je fait MACDline[12,26,9](close)[indicemax2], et bien j'ai un résultat complètement faux, alors que dans le même temps la variable indicemax2 est bien valorisé.
Pour palier au problème je suis obligé de stocker la valeur du macd dans une variable à chaque fois que je met la variable indicemax à jour, la variable macd est correctement valorisé.
Visiblement l'appel de fonction avec des variables ne parait pas très fiable, avez vous déjà rencontré ce genre de problème ?
Code : #
max1 = 0
max2 = 0
indicemax1 = 0
indicemax2 = 0
result = 0
macd1 = 0
macd2 = 0
for i=1 to 20 do
if high[i] > max1 then
max2 = max1
indicemax2 = indicemax1
max1 = high[i]
indicemax1 = i
macd2 = macd1
macd1 = MACDline[12,26,9](close)[i]
endif
next
if high > max1 then
max2 = max1
indicemax2 = indicemax1
indicemax1 = 0
macd2 = macd1
macd1 = MACDline[12,26,9](close)[0]
else
if high > max2 then
indicemax2 = 0
max2 = high
macd2 = MACDline[12,26,9](close)[0]
endif
endif
if indicemax1 < indicemax2 then
if MACDline[12,26,9](close)[indicemax1] < MACDline[12,26,9](close)[indicemax2] then
result = 10
endif
endif
return indicemax1 as "indicemax1", indicemax2 as"indicemax2", result as "result", macd1 as "macd indicemax1", macd2 as "macd indicemax2", max1 as "1", max2 as "2", MACDline[12,26,9](close)[indicemax1] as "MAcd bug variable indice 1", MACDline[12,26,9](close)[indicemax2] as "MAcd bug variable indice 2"