[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re : ELA CODE - > DUNN'S DENSITY INDICATOR



PureBytes Links

Trading Reference Links

Dans un courrier daté du 04/10/98 22:40:52  , vous avez écrit :

<< DUNN'S DENSITY OF CLOSES
 
 What Does It Do
 //////////////////////////
 It looks at the last 10 days of closes and check one days close against the
previous days close and then is +1 or -1. The indicator can swing from -10 to
10. My hope is that an increasing number of closes in a certain direction
maybe a lead indicator for a new trend when combined with moving averages etc.
 >>

Here is a modified and more general version of your code, allowing to use it
with any lookback period, and not only on close.

You can divide the result by 0.5*len to normalize it.

As a hint, it always better to use for lops to perform repetitive calculation
and allow as input anything that could be changed later.

Sincerely,
Pierre Orphelin


===============general version==============
{
 DUNN'S DENSITY INDICATOR
EL code by Pierre Orphelin
www.sirtrade.com
}

inputs: price(c), len(10);

vars: k(0),diff(0),tmp(0),tmp2(0);
diff=price-price[1];
tmp2=0;
for k=0 to len-1 begin
	tmp=0;	
	if diff[k]<>0 then tmp=iff(diff[k]>0,1,-1);
	tmp2=tmp2+tmp;
end;

plot1(tmp2,"densityC");
plot2(0, "mid");

 =================end ===================



=============original code===================  
 {Dunn's Density}
 {Paste this in as an INDICATOR...or paste it into a system}
 
 Value1= C-C[1];
 Value2= C[1]-C[2];
 Value3= C[2]-C[3];
 Value4= C[3]-C[4];
 Value5= C[4]-C[5];
 Value6= C[5]-C[6];
 Value7= C[6]-C[7];
 Value8= C[7]-C[8];
 Value9= C[8]-C[9];
 Value10= C[9]-C[10];
 value11=0;
 value12=0;
 
 If Value1 > 0 then value11=value11+1;
 If Value1 < 0 then value11=value11-1;
 If Value2 > 0 then value11=value11+1;
 If Value2 < 0 then value11=value11-1;
 If Value3 > 0 then value11=value11+1;
 If Value3 < 0 then value11=value11-1;
 If Value4 > 0 then value11=value11+1;
 If Value4 < 0 then value11=value11-1;
 If Value5 > 0 then value11=value11+1;
 If Value5 < 0 then value11=value11-1;
 If Value6 > 0 then value11=value11+1;
 If Value6 < 0 then value11=value11-1;
 If Value7 > 0 then value11=value11+1;
 If Value7 < 0 then value11=value11-1;
 If Value8 > 0 then value11=value11+1;
 If Value8 < 0 then value11=value11-1;
 If Value9 > 0 then value11=value11+1;
 If Value9 < 0 then value11=value11-1;
 If Value10 > 0 then value11=value11+1;
 If Value10 < 0 then value11=value11-1;
 
 plot1(value11, "densityC");
 plot2(0, "mid");