I am going to try and answer my own question. StochD is a 3 period average of %k, so even though t = t1 for one day, x and x1 will not be equal.
James ________________________________ From: James <[email protected]> To: [email protected] Sent: Mon, March 15, 2010 9:31:29 AM Subject: [amibroker] Need help with formula calculation Hello, Following is some slightly modified code originally introduced by D. Tsokakis. I obviously do not understand how the formula calculates x1. It seems to me that when k1 or k2 = 0, then t1 will equal t. This is because coeff*k1 or coeff*k2 would equal 0. If t = t1 then x would equal x1, and the two graphs should be equal at this point. However, this is clearly not what is going on when you look at this on a chart. Can someone tell me what I am missing here? 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);
