Overblog Suivre ce blog
Editer l'article Administration Créer mon blog
8 mars 2008 6 08 /03 /mars /2008 19:09

Unités de temps journalière et hebdomadaire : les bandes de Bollinger et les moyennes 7 et 23.

Sur le même principe que celui utilisé pour le code "monthly", voici les codes des programmes qui permettent de sortir les données hebdomadaires et journalières sur des unités de temps inférieures.

//////////////// unité de temps hebdomadaire /////////////
once haut=high
once bas = low
haut=max(haut,high)
bas=min(bas,low)
if dayofweek < dayofweek[1] then
    a22=a21
    a21=a20
    a20=a19
    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
    prev7=moy7[1]
    prev23=moy23[1]
    prevmb=mb[1]
    prevub=ub[1]
    prevlb=lb[1]
endif
moy7=(close+a1+a2+a3+a4+a5+a6)/7
moy23=(close+a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20+a21+a22)/23
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)
ub=mb+(2*ecart)
lb=mb-(2*ecart)
if zz<7 then
    moy7=undefined
endif
if zz<23 then
    moy23=undefined
endif
if zz<20 then
    mb=undefined
    ub=undefined
    lb=undefined
endif
cond23=moy23-prev23
cond7=moy7-prev7
condmb=mb-prevmb
condub=ub-prevub
condlb=lb-prevlb

return moy7 coloured by cond7,moy23 coloured by cond23,mb coloured by condmb,ub coloured by condub,lb coloured by condlb

///////////////// unité de temps daily /////////////:
if dayofweek <> dayofweek[1] then
    a22=a21
    a21=a20
    a20=a19
    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=dclose(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=dhigh(1)
    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=dlow(1)
    zz=zz+1
    prev7=moy7[1]
    prev23=moy23[1]
    prevmb=mb[1]
    prevub=ub[1]
    prevlb=lb[1]
endif
moy7=(close+a1+a2+a3+a4+a5+a6)/7
moy23=(close+a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20+a21+a22)/23
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+dlow(0)+dhigh(0))/3+tp1+tp2+tp3+tp4+tp5+tp6+tp7+tp8+tp9+tp10+tp11+tp12+tp13+tp14+tp15+tp16+tp17+tp18+tp19)/20
vola=((square((close+dlow(0)+dhigh(0))/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)
ub=mb+(2*ecart)
lb=mb-(2*ecart)
if zz<7 then
    moy7=undefined
endif
if zz<23 then
    moy23=undefined
endif
if zz<20 then
    mb=undefined
    ub=undefined
    lb=undefined
endif
cond23=moy23-prev23
cond7=moy7-prev7
condmb=mb-prevmb
condub=ub-prevub
condlb=lb-prevlb

return moy7 coloured by cond7,moy23 coloured by cond23,mb coloured by condmb,ub coloured by condub,lb coloured by condlb

Edit le 10/03/08, les conditions pour la coloration (en rose) sont modifiées.

Partager cet article

Repost 0

commentaires