///////////////////////////////////////////////////////
/////////////SIBBET DEMAND INDEX////////////////
//////////////////////////////////////////////////////
//{Programmed by David Fenstemaker}
//{Omega Code downloaded from}
//{http://www.purebytes.com/archives/omega/2002/msg04345.html}
//{converted to MS by wabbit here}
//http://www.stator-afm.com/demand-index.html
//tradotto per PRT da tetsuo
//{04 April 2008}
//creare la variabile len(11)
len=11
if barindex<=1 then
volavg=volume
else
volavg=(volavg[1]*(len-1)+volume)/len
endif
if barindex>len then
wcl=(high+low+close+close)/4
avgTR=average[len](highest[2](high)-lowest[2](low))
If Wcl <> 0 and wcl[1] <> 0 and AvgTR <> 0 and VolAvg <> 0 then
wtcratio=(wcl-wcl[1])/(min(wcl,wcl[1]))
volratio=volume/volavg
const2=((wcl*3)/avgtr)*abs(wtcratio)
const=volratio/exp(min(const2,88))
if wtcratio>0 then
buypr=volratio
sellpr=const
else
buypr=const
sellpr=volratio
endif
buypress=(buypress[1]*(len-1)+buypr)/len
sellpress=(sellpress[1]*(len-1)+sellpr)/len
tempdi=1
if sellpress>buypress then
sign=-1
else
sign=1
endif
if sellpress>buypress then
tempDI=sign*(buypress/sellpress)
else
tempDI=sign*(sellpress/buypress)
endif
if tempDI<0 then
myDMI=100*(-1-tempDI)
else
myDMI=100*(1-tempDI)
endif
endif
endif
return mydmi coloured(0,0,255) as "DEMAND INDEX", 0
/////////////////////////FINE///////////////////////////