Samedi 22 mars 2008
6
22
/03
/Mars
/2008
12:33
La volatilité normalisée en unités de temps hebdomadaire et mensuelle.
Dernier article sur les indicateurs, je vous présente le code des programmes qui retournent la volatilité normalisée pour l'unité de temps supérieure. Voici une vue de JPM, avec l'indicateur weekly dans la seconde fenêtre : l'historigramme blanc/noir signale une cloture en dehors des bandes de Bollinger. Pour la volatilité de référence qui est normalement de 150, j'ai simplement multiplié ce nombre par 5 et 21 pour l'indicateur week et month : les valeurs ne sont donc pas rigoureusement exactes.
Et maintenant le code pour Prorealtime :
////////// unité weekly : volatilité normalisée ////////////
once haut=high
once bas = low
haut=max(haut,high)
bas=min(bas,low)
if dayofweek < dayofweek[1] then
a19=a18
a18=a17
a17=a16
a16=a15
a15=a14
a14=a13
a13=a12
a12=a11
a11=a10
a10=a9
a9=a8
a8=a7
a7=a6
a6=a5
a5=a4
a4=a3
a3=a2
a2=a1
a1=close[1]
h19=h18
h18=h17
h17=h16
h16=h15
h15=h14
h14=h13
h13=h12
h12=h11
h11=h10
h10=h9
h9=h8
h8=h7
h7=h6
h6=h5
h5=h4
h4=h3
h3=h2
h2=h1
h1=haut[1]
haut=high
l19=l18
l18=l17
l17=l16
l16=l15
l15=l14
l14=l13
l13=l12
l12=l11
l11=l10
l10=l9
l9=l8
l8=l7
l7=l6
l6=l5
l5=l4
l4=l3
l3=l2
l2=l1
l1=bas[1]
bas=low
zz=zz+1
prevec=vfin[1]
else
endif
tp1=(h1+l1+a1)/3
tp2=(h2+l2+a2)/3
tp3=(h3+l3+a3)/3
tp4=(h4+l4+a4)/3
tp5=(h5+l5+a5)/3
tp6=(h6+l6+a6)/3
tp7=(h7+l7+a7)/3
tp8=(h8+l8+a8)/3
tp9=(h9+l9+a9)/3
tp10=(h10+l10+a10)/3
tp11=(h11+l11+a11)/3
tp12=(h12+l12+a12)/3
tp13=(h13+l13+a13)/3
tp14=(h14+l14+a14)/3
tp15=(h15+l15+a15)/3
tp16=(h16+l16+a16)/3
tp17=(h17+l17+a17)/3
tp18=(h18+l18+a18)/3
tp19=(h19+l19+a19)/3
mb=((close+bas+haut)/3+tp1+tp2+tp3+tp4+tp5+tp6+tp7+tp8+tp9+tp10+tp11+tp12+tp13+tp14+tp15+tp16+tp17+tp18+tp19)/20
vola=((square((close+bas+haut)/3)+square(tp1)+square(tp2)+square(tp3)+square(tp4)+square(tp5)+square(tp6)+square(tp7)+
square(tp8)+square(tp9)+square(tp10)+square(tp11)+square(tp12)+square(tp13)+square(tp14)+square(tp15)+square(tp16)+
square(tp17)+square(tp18)+square(tp19))/20)-square(mb)// ATTENTION, à recoller au montage si nécessaire !!
ecart=sqrt(vola)
if zz<20 then
mb=undefined
lb=undefined
ub=undefined
endif
lb=mb-(ecart*2)
ub=mb+(2*ecart)
vola=ecart/mb
vmin=lowest[750](vola)
vmax=highest[750](vola)
vfin=(vola-vmin)/(vmax-vmin)
condvol=vfin-prevec
if close<lb then
flagb=-.1
else
flagb=0
endif
if close>ub then
flagh=-.1
else
flagh=0
endif
return vfin coloured by condvol,flagb,flagh
///////////// unité mois : volatilité normalisée //////////////
once bas = low
once haut= high
haut=max(haut,high)
bas=min(bas,low)
jour=Date MOD 1000000
moi= jour mod 10000
jour=moi mod 100
moi=(moi-jour)/100
if moi <> moi[1] then
a19=a18
a18=a17
a17=a16
a16=a15
a15=a14
a14=a13
a13=a12
a12=a11
a11=a10
a10=a9
a9=a8
a8=a7
a7=a6
a6=a5
a5=a4
a4=a3
a3=a2
a2=a1
a1=close[1]
h19=h18
h18=h17
h17=h16
h16=h15
h15=h14
h14=h13
h13=h12
h12=h11
h11=h10
h10=h9
h9=h8
h8=h7
h7=h6
h6=h5
h5=h4
h4=h3
h3=h2
h2=h1
h1=haut[1]
haut=high
l19=l18
l18=l17
l17=l16
l16=l15
l15=l14
l14=l13
l13=l12
l12=l11
l11=l10
l10=l9
l9=l8
l8=l7
l7=l6
l6=l5
l5=l4
l4=l3
l3=l2
l2=l1
l1=bas[1]
bas=low
zz=zz+1
prevec=vfin[1]
else
endif
tp1=(h1+l1+a1)/3
tp2=(h2+l2+a2)/3
tp3=(h3+l3+a3)/3
tp4=(h4+l4+a4)/3
tp5=(h5+l5+a5)/3
tp6=(h6+l6+a6)/3
tp7=(h7+l7+a7)/3
tp8=(h8+l8+a8)/3
tp9=(h9+l9+a9)/3
tp10=(h10+l10+a10)/3
tp11=(h11+l11+a11)/3
tp12=(h12+l12+a12)/3
tp13=(h13+l13+a13)/3
tp14=(h14+l14+a14)/3
tp15=(h15+l15+a15)/3
tp16=(h16+l16+a16)/3
tp17=(h17+l17+a17)/3
tp18=(h18+l18+a18)/3
tp19=(h19+l19+a19)/3
mb=((close+bas+haut)/3+tp1+tp2+tp3+tp4+tp5+tp6+tp7+tp8+tp9+tp10+tp11+tp12+tp13+tp14+tp15+tp16+tp17+tp18+tp19)/20
vola=((square((close+bas+haut)/3)+square(tp1)+square(tp2)+square(tp3)+square(tp4)+square(tp5)+square(tp6)+square(tp7)+
square(tp8)+square(tp9)+square(tp10)+square(tp11)+square(tp12)+square(tp13)+square(tp14)+square(tp15)+square(tp16)+
square(tp17)+square(tp18)+square(tp19))/20)-square(mb)// ATTENTION, à recoller au montage si nécessaire !!
ecart=sqrt(vola)
if zz<20 then
mb=undefined
lb=undefined
ub=undefined
endif
lb=mb-(ecart*2)
ub=mb+(2*ecart)
vola=ecart/mb
vmin=lowest[3150](vola)
vmax=highest[3150](vola)
vfin=(vola-vmin)/(vmax-vmin)
condvol=vfin-prevec
if close<lb then
flagb=-.1
else
flagb=0
endif
if close>ub then
flagh=-.1
else
flagh=0
endif
return vfin coloured by condvol,flagb,flagh