Best regards,
James Karn
/*TREND DETECTOR WITH VARIABLE PERIOD, by D. Tsokakis, Apr2003*/
t=20;
x=DEMA(StochD(40),t);
Plot(x,"",1,8);
Cond1=Ref(x,-1)==LLV(x,3);
Plot(50*Cond1,"",5,2);
Cond2=Ref(x,-1)==HHV(x,3);
Plot(50*Cond2,"",4,2);
k1=BarsSince(Cond1);
k2=BarsSince(Cond2);
Plot((k2>k1)*10,"",5,2);
Plot((k2<k1)*10,"",4,2);
t1=IIf(k2>k1,t+coeff*k1,t+coeff*k2);// if k1 or k2 = 0, then t1 = t ?
x1=DEMA(StochD(40),t1);// if t1 = t, then x1 = x ?
Plot(x1,"",(x1>Ref(x1,-1))*5+(x1<Ref(x1,-1))*4,8);
GraphXSpace=1;
"x: " + NumToStr( x, 1.4);
"k1: " + NumToStr( k1, 1.0);
"k2: " + NumToStr( k2, 1.0);
"t1: " + NumToStr( t1, 1.0);
"x1: " + NumToStr( x1, 1.4);