Bonjour,
j’aimerais tester un truc, mais je ne sais pas si c’est possible. Je voudrais savoir à quel niveau de moyenne mobile simple correspond un prix.
Grosse modo je voudrais résoudre cette équation :
Close = summation[x](close)/X
X=???
Je sais pas si c’est assez clair ? Possible ou pas ?
Merci d’avance pour votre réponse :).
JSParticipant
Senior
Salut,
Je l’ai essayé pour vous, mais la chance que la moyenne soit exactement égale au prix est négligeable…
Found=0
N=1000 //Maximum Period
CloseTarget = Close // The closing price you're comparing against
FOR x = 2 TO N // You can adjust to any maximum period you want
SMAX = average[x](Close) // Calculate the moving average for X periods
IF (SMAX = CloseTarget) THEN
Found = 1
break // Stop the loop when a match is found
ENDIF
NEXT
DrawText("x=#x#", BarIndex, High+5)
DrawText("Found=#Found#",BarIndex, Low-5)
RETURN
Bonjour,
Un grand merci !!! après quelques modifications, j’y suis arrivé. C’est déjà pas mal comme résultat, mieux que rien ^^
j’ai rajouté un screenshot pour une idée du visuel.
Found=0
N=100 //Maximum Period
CloseTarget = high
// The closing price you're comparing against
FOR x = 2 TO N // You can adjust to any maximum period you want
SMAX = average[x](Close) // Calculate the moving average for X periods
IF (SMAX => CloseTarget-5 and SMAX<=closetarget+5) THEN
Found = 1
//DrawText("x=#x#", BarIndex, High+5)
//DrawText("Found=#Found#",BarIndex, Low-5)
//ELSE
//found=0
break // Stop the loop when a match is found
ENDIF
NEXT
c1= found=1 and smax=Average[7](close)
if c1 THEN
DrawText("x=#x#", BarIndex, High+5)
endif
RETURN c1//smax
Mais vous avez raison, c’est compliqué de tomber sur la valeur d’une moyenne mobile. Je vais voir si je m’en sors. Je cherche à identifier à quel moyenne mobile un pic et un creux peut correspondre.
JSParticipant
Senior
Bonjour,
Vous pouvez également regarder la régression linéaire (méthode des moindres carrés)…