Hello All,
ci-dessous un code pour calculer les points pivots mensuels.
Qd posé sur le graphe, cet indicateur donne exactement le même résultat que l’indicateur points pivots de PRT.
if (month > month[1]) or (month=1 and month[1]=12) then
monthHigh = prevMonthHigh
monthLow = prevMonthLow
monthClose = prevMonthClose
prevMonthHigh = high
prevMonthLow = low
endif
prevMonthHigh = max(prevMonthHigh, high)
prevMonthLow = min(prevMonthLow, low)
prevMonthClose = close
p = (monthHigh + monthLow + monthclose) / 3
S1 = (p*2)-monthHigh
S2 = p-(monthHigh-monthLow)
S3 = monthLow-2*(monthHigh-p)
Res1 = (p*2)-monthLow
Res2 = p+(monthHigh-monthLow)
Res3 = monthHigh+2*(p-monthLow)
return p, S1 as "S1", S2 as "S2", S3 as "S3", Res1 as "R1", Res2 as "R2", Res3 as "R3"
Mais, ce même indicateur appelé dans un backtest donne des valeurs différentes, pas de bcp.
Sur l’image en bleu les points pivot PRT égaux aux points pivots du code ci-dessus et en noir les points pivots du code ci-dessus appelés dans le backtest.
Qq a une explication ou a déjà rencontré un problème similaire?
F.
Il n’y a peut-être pas suffisamment de bars dans l’historique quand tu lances ton back test. Il faudrait peut-être en ajouter avec preloadbars.
Je viens d’essayer mais ca n’a pas d’effet.
Voici le code du backtest que j’ai minimisé au max:
DEFPARAM PRELOADBARS = 300
pp, ignored, ignored, ignored, ignored, ignored, ignored = CALL "Pivot Points Monthly"
graph pp
//graph myS1
//graph myS2
//graph myS3
//graph myR1
//graph myR2
//graph myR3
if 0 = 1 then
buy 1 cash at close limit
endif
La seule chose qui me vient à l’esprit est un problème d’arrondi.
A propos j’utilise la version journalière, peut-être que les données affichées et les données du backtest diffèrent?
Bonjour,
Regarde sur PRT si la bonne formule du calcul du point pivot est utilisé.
3 sorte de calculs pour déterminer un point pivot journalier.
(h+b+c)/3
(h+b+c+o du jour)/4 —-> o.du mois pour toi
(h+b+o du jour)/3 ——>o. du mois pour toi
Salutations
Je ne saurai pas expliqué pourquoi cette différence mais en modifiant le code de l’indicateur comme ci-dessous, ca fonctionne.
if (month > month[1]) or (month=1 and month[1]=12) then
monthHigh = prevMonthHigh
monthLow = prevMonthLow
monthClose = prevMonthClose
prevMonthHigh = high
prevMonthLow = low
else
prevMonthHigh = max(prevMonthHigh, high)
prevMonthLow = min(prevMonthLow, low)
prevMonthClose = close
endif
p = (monthHigh + monthLow + monthclose) / 3
S1 = (p*2)-monthHigh
S2 = p-(monthHigh-monthLow)
S3 = monthLow-2*(monthHigh-p)
Res1 = (p*2)-monthLow
Res2 = p+(monthHigh-monthLow)
Res3 = monthHigh+2*(p-monthLow)
return p, S1 as "S1", S2 as "S2", S3 as "S3", Res1 as "R1", Res2 as "R2", Res3 as "R3"