I never suggested it was your code ... I only stated that FFT's can 
be calculated relatively quickly in AFL ... You can use one or more 
of the algorithms I pointed you at or wait for TJ to implement it in 
AB.

--- In [email protected], "Ton Sieverding" 
<[EMAIL PROTECTED]> wrote:
>
> 1. Speed problems resulting from piggy code with indicators can be 
> observed by holding down the left or right arrow keys traveling 
bar 
> to bar and seeing how much lag time there is.
> 
> Thats what I have done and how I observed the speed problem ...
> 
> 2. There is no reason an FFT should have this sort of response 
time ergo 
> the first F in FFT ...
> 
> Please read rest of this email conversation and you will 
understand that the code does not has my signature ( Author = 
Dmitris Tsokasis ) and that I am still wondering what it really 
does. But thanks again for the remarks ...
> 
> Ton.
> 
> 
>   ----- Original Message ----- 
>   From: Fred 
>   To: [email protected] 
>   Sent: Wednesday, September 13, 2006 3:02 PM
>   Subject: [amibroker] Re: Cycles and Mesa
> 
> 
>   My point was ... there should be NO speed problems ... 
Personally I 
>   find response time for FFT calculations over thousands of bars 
to 
>   still be subsecond.
> 
>   Speed problems resulting from piggy code with indicators can be 
>   observed by holding down the left or right arrow keys traveling 
bar 
>   to bar and seeing how much lag time there is.
> 
>   There is no reason an FFT should have this sort of response time 
ergo 
>   the first F in FFT ...
> 
>   If you have code for an FFT ( which I have yet to see anyone 
post 
>   here or in the files section ) and it has a lot of lag 
associated 
>   with it, I suggest you hunt down code on the net for a more 
efficient 
>   implementation. 
> 
>   For example ... here's a page of FFT routines in a variety of 
>   languages that fill the bill ... For those that are C challenged 
>   there are easily translatable other flavors ... 
> 
>   http://faculty.prairiestate.edu/skifowit/fft/ 
> 
>   --- In [email protected], "Ton Sieverding" 
>   <ton.sieverding@> wrote:
>   >
>   > "Writing efficient AFL for either is fairly straight forward 
with 
>   no 
>   > need for extra hardware ( FFT Chips ?! ) or DLL's ..." 
>   > Sure as long as you accept delays of several minutes when 
using 
>   this code. This has nothing to do with AFL or AB but is just 
what you 
>   get when running Fourier Analysis for financial timeseries. 
That's 
>   why I am asking if other members have some experience and how 
they 
>   did solve the speed problem, But thanks for you advise anyway ...
>   > 
>   > Ton.
>   > 
>   > 
>   > ----- Original Message ----- 
>   > From: Fred 
>   > To: [email protected] 
>   > Sent: Tuesday, September 12, 2006 4:29 PM
>   > Subject: [amibroker] Re: Cycles and Mesa
>   > 
>   > 
>   > Formulas and/or algorithms for FFT's are available a zillion 
>   places 
>   > on the net although I wouldn't bother with the one at 
numerical 
>   > recipes. Formulas for MESA are also available on net although 
>   they 
>   > are a little harder to find as I think someone who is probably 
>   the 
>   > best known for this technique although not the originator of 
the 
>   > algorithm or even its use with price data has done his best to 
>   > squelch a lot of what otherwise would be available.
>   > 
>   > Writing efficient AFL for either is fairly straight forward 
with 
>   no 
>   > need for extra hardware ( FFT Chips ?! ) or DLL's ...
>   > 
>   > --- In [email protected], "Ton Sieverding" 
>   > <ton.sieverding@> wrote:
>   > >
>   > > Thanks Tomasz. First I do not understand why it involves 
3.000 
>   * ( 
>   > Bars# ) * ( Bars# ). Why not just 3.000 * ( Bars# ) ? I did 
the 
>   same 
>   > test in Excel with 3.000 * ( Bars# ) and got no delay. After 
your 
>   > email I did it again with 3.000 * ( Bars# ) * ( Bars# ) and 
got a 
>   > delay of several minutes. But why two times 1.000 ?
>   > > Secondly I just copied the code I got from Fred and tried to 
>   speed 
>   > it up by removing the second and third harmonic calculation. 
Of 
>   > course it was faster but still to slow for me. Frankly I do 
not 
>   > understand how you can remove Cum() and LastValue() as the 
>   results 
>   > are being used for the calculation of the harmonic.
>   > > Finally I agree that Log calculations will speed up the 
process 
>   and 
>   > will look for FFT code that does use Log's. I only have used 
full 
>   > Fourier Analysis in electronics and have no experience with 
the 
>   Fast 
>   > Fourier Transform. Although I agree with Ara that a FFT card 
is 
>   > probably needed for the real good performance. Do you have any 
>   > experience with these goodies ?
>   > > 
>   > > Ton.
>   > > 
>   > > ----- Original Message ----- 
>   > > From: Tomasz Janeczko 
>   > > To: [email protected] 
>   > > Sent: Thursday, September 07, 2006 1:32 PM
>   > > Subject: Re: [amibroker] Re: Cycles and Mesa
>   > > 
>   > > 
>   > > 
>   > > Hello,
>   > > 
>   > > You are doing 24 * 16 * 8 * (NUMBER OF BARS) iterations per 
bar 
>   > (in the most inner loop you are using Cum() function which is 
>   > cummulative
>   > > sum over all bars). So entire execution involves 24 * 16 * 8 
* 
>   > (Number of bars) * (Number of bars). If you say have 1000 bars 
>   you 
>   > end up with
>   > > 3 billion operations.
>   > > To speed it up you would need to REMOVE Cum() and LastValue
() 
>   > from inner loop (they are not needed in fact).
>   > > 
>   > > The code below is a sample of very inefficient coding. 
Properly 
>   > coded FFT requires only N*logN operations
>   > > 
>   > > Best regards,
>   > > Tomasz Janeczko
>   > > amibroker.com
>   > > ----- Original Message ----- 
>   > > From: Ton Sieverding 
>   > > To: [email protected] 
>   > > Sent: Wednesday, September 06, 2006 12:16 PM
>   > > Subject: Re: [amibroker] Re: Cycles and Mesa
>   > > 
>   > > 
>   > > Rakesh when talking about the Fourier code ( Fred -> 
Ehler ? ) 
>   > you sent me and looking for what you want to get, why not just 
>   taking 
>   > the first harmonic and forgetting the rest of the code. In 
this 
>   way 
>   > you have your current cycle length - at least this is what I 
>   think 
>   > you want to get - and this will also solve an important part 
of 
>   the 
>   > speed problem. So take Y01 and take out the linear Y and you 
>   should 
>   > get the first harmonic. But as I already told you, this is not 
>   what I 
>   > have in mind for the first harmonic ...
>   > > 
>   > > Also I do not understand why this code is still so slow. 
When 
>   > looking to the For Loops I am getting 24 * 16 * 8 being 3.072 
>   > iterations per Bar. So why is the code so slow ? Thomasz am I 
to 
>   > optimistic ? Dimitri do you have any idea ? You can speedup 
the 
>   > calculation by setting n = 6, g01=1.0 ( starting g=1 ) and 
stp0 = 
>   200 
>   > ( starting stp0 = 400 ). I do not see any difference in the 
graph 
>   and 
>   > the speed should be of course 12 * 8 * 4 = 384 or 8x the old 
>   > speed ... 
>   > > 
>   > > Ton.
>   > > 
>   > > 
>   > > 
>   > > _SECTION_BEGIN("Fourier Analysis Elementary"); 
>   > > // 
>   > ============================================================= 
>   > > // Elementary Fourier analysis, by D. Tsokakis, May 2004 
>   > > // 
>   > ============================================================= 
>   > > t=Cum(1)-1; 
>   > > A=Param("Rsi",50,1,100,1); 
>   > > B=Param("smooth",100,1,120,1); 
>   > > C1=MA(RSI(A),B); 
>   > > start=Cum(IsTrue(C1))==1; 
>   > > t1=ValueWhen(start,t); 
>   > > 
>   > > // PlotShapes(shapeDownTriangle*start,colorYellow); 
>   > > 
>   > > // C10=ValueWhen(start,C1);Plot(C1,"C1",colorBlack,8); 
>   > > GraphXSpace=2; 
>   > > x = Cum(1); 
>   > > lastx = LastValue( x ); 
>   > > Daysback = LastValue(Cum(IsTrue(C1))); 
>   > > aa = LastValue( LinRegIntercept( C1, Daysback) ); 
>   > > bb = LastValue( LinRegSlope( C1, Daysback ) ); 
>   > > yy = Aa + bb * ( x - (Lastx - DaysBack) ); 
>   > > yy=IIf( x >= (lastx - Daysback), yy, -1e10 ); 
>   > > 
>   > > // Plot( yy, "yy", colorRed ); 
>   > > detrend=C1-yy; 
>   > > new1=detrend;
>   > > Hor=LastValue(Cum(new1)/Cum(IsTrue(C1))); 
>   > > pi=4*atan(1);
>   > > n=12; 
>   > > 
>   > > // =============================================== 
>   > > // Fundamental period, crude approximation 
>   > > // =============================================== 
>   > > 
>   > > error00=10000;
>   > > per01=0;
>   > > g01=0;
>   > > phi01=0;
>   > > stg0=0.5;
>   > > stp0=100; 
>   > > 
>   > > for(phi=0;phi<2*pi;phi=phi+pi/n) 
>   > > { 
>   > > for(g=0.5;g<=8;g=g+stg0) 
>   > > { 
>   > > for(per=300;per<=1000;per=per+stp0) 
>   > > { 
>   > > f=1/per; 
>   > > y=Hor+g*sin(2*pi*f*(t-t1)+phi); 
>   > > error=LastValue(Cum(abs(y-new1))); 
>   > > if(error<error00) 
>   > > {error00=error;per01=per;g01=g;phi01=phi;} 
>   > > } 
>   > > } 
>   > > } 
>   > > 
>   > > f01=1/per01;
>   > > y01=Hor+g01*sin(2*pi*f01*(t-t1)+phi01); 
>   > > 
>   > > Plot(y01,"y01",colorRed,4); 
>   > > 
>   > > _SECTION_END(); 
>   > > 
>   > > 
>   > > ----- Original Message ----- 
>   > > From: Ara Kaloustian 
>   > > To: [email protected] 
>   > > Sent: Wednesday, September 06, 2006 6:12 AM
>   > > Subject: Re: [amibroker] Re: Cycles and Mesa
>   > > 
>   > > 
>   > > 
>   > > Rakesh,
>   > > 
>   > > John Ehler's code is quite usable with AB... it produces the 
>   > dominant cycle value. It is a bit CPU intensive but I tried 
using 
>   it 
>   > at the start of a new bar (instead of using it with every 
trade) 
>   and 
>   > that made the CPU load quite acceptable.
>   > > 
>   > > My issue with both Ehler's code anf FFT is that I was not 
>   > satisfied with either.
>   > > 
>   > > Since you were getting good results with FFT, you might try 
>   > Ehler's code.
>   > > 
>   > > Theoretically ehler's code should be better since it looks 
at 
>   > the most recent data, while FFT would need much longer data to 
>   > produce usefuk cycle lengths.
>   > > 
>   > > Good luck
>   > > 
>   > > Ara
>   > > ----- Original Message ----- 
>   > > From: Rakesh Sahgal 
>   > > To: [email protected] 
>   > > Sent: Tuesday, September 05, 2006 5:33 PM
>   > > Subject: Re: [amibroker] Re: Cycles and Mesa
>   > > 
>   > > 
>   > > Ton
>   > > 
>   > > Back in the old MetaStock days I had fiddled around with 
>   > using the packaged FFT in MS. I had used it to extract the 
>   current 
>   > dominant cycle length in a market and then used it to compute 
>   > studies. The results were quite satisfactory. Then I changed 
>   > platforms to AB and the whole idea got shelved. Subsequently I 
>   have 
>   > tried to find a way of extracting current dominant cycle 
length 
>   in an 
>   > issue/market in AB but have not seen any way of using it which 
my 
>   non-
>   > engineering/mathmetician brain could comprehend. It was in 
this 
>   > context I tried DT's code. Unfortunately (a) it was computing 
>   power 
>   > intensive and (b) the results were beyond my comprehension so 
I 
>   gave 
>   > up on it. I still would like to find a way of ascertaining 
what 
>   the 
>   > current cycle length is in an issue but have not been able to 
>   make 
>   > much progress. Perhaps someone on the list could throw up some 
>   ideas 
>   > which are implementable on the AB platform.
>   > > 
>   > > 
>   > > R
>   > > 
>   > > 
>   > > On 9/6/06, Ton Sieverding <ton.sieverding@> wrote: 
>   > > Thanks Rakesh. I've tried underneath mentioned AFL code 
>   > for Fourier analysis. It does something but I have some 
>   questions :
>   > > 
>   > > 1. I have the feeling that the code uses a lot of 
>   > computer power. When modifying the parameters it takes several 
>   > seconds ( about 5 sec ) before I have a result on the graph. I 
am 
>   > using a Ghz 2.6 CPU with 1GB internal and have never seen my 
>   computer 
>   > so slow. Do you have the same experience ? 
>   > > 2. What I would like to see is a couple of sine waves 
>   > being the harmonics of the original time series. So more or 
less 
>   the 
>   > same picture as Fred's Cycles. But that's not what I get. Also 
>   the 
>   > calculations for the Fourier analysis does not look familiar 
to 
>   me. 
>   > Where can I find the logical background behind these formulas ?
>   > > 
>   > > Ton.
>   > > 
>   > > 
>   > > ----- Original Message ----- 
>   > > From: Rakesh Sahgal 
>   > > To: [email protected] 
>   > > Sent: Tuesday, September 05, 2006 2:12 PM
>   > > Subject: Re: [amibroker] Re: Cycles and Mesa
>   > > 
>   > > 
>   > > If you are interested in Fourier Analysis in AB 
>   > environment you should refer to the work of Dmitris Tsokasis 
who 
>   > shared his work on Fourier Analysis with the group. Am pasting 
>   below 
>   > his code. I have never used it and would not know how to apply 
it 
>   in 
>   > a meaningful manner. Hope you find it useful.
>   > > 
>   > > 
>   > > R
>   > > 
>   > > 
>   > > ===============================
>   > > // Elementary Fourier analysis, by D. Tsokakis, May 2004
>   > > 
>   > > t=Cum(1)-1;
>   > > 
>   > > A=Param("Rsi",50,1,100,1);
>   > > 
>   > > B=Param("smooth",100,1,120,1);
>   > > 
>   > > C1=MA(RSI(A),B);
>   > > 
>   > > start=Cum(IsTrue(C1))==1;
>   > > 
>   > > t1=ValueWhen(start,t);
>   > > 
>   > > PlotShapes(shapeDownTriangle*start,colorYellow); 
>   > > 
>   > > C10=ValueWhen(start,C1);Plot(C1,"C1",colorBlack,8);
>   > > 
>   > > GraphXSpace=2;
>   > > 
>   > > x = Cum(1);
>   > > 
>   > > lastx = LastValue( x );
>   > > 
>   > > Daysback = LastValue(Cum(IsTrue(C1)));
>   > > 
>   > > aa = LastValue( LinRegIntercept( C1, Daysback) );
>   > > 
>   > > bb = LastValue( LinRegSlope( C1, Daysback ) );
>   > > 
>   > > yy = Aa + bb * ( x - (Lastx - DaysBack) );
>   > > 
>   > > yy=IIf( x >= (lastx - Daysback), yy, -1e10 );
>   > > 
>   > > Plot( yy, "yy", colorRed );
>   > > 
>   > > detrend=C1-yy;
>   > > 
>   > > new1=detrend;Hor=LastValue(Cum(new1)/Cum(IsTrue(C1)));
>   > > 
>   > > pi=4*atan(1);n=12;
>   > > 
>   > > // Fundamental period, crude approximation
>   > > 
>   > > error00=10000;per01=0;g01=0;phi01=0;stg0=0.5;stp0=100;
>   > > 
>   > > for(phi=0;phi<2*pi;phi=phi+pi/n)
>   > > 
>   > > {
>   > > 
>   > > for(g=0.5;g<=8;g=g+stg0)
>   > > 
>   > > {
>   > > 
>   > > for(per=300;per<=1000;per=per+stp0)
>   > > 
>   > > {f=1/per;
>   > > 
>   > > y=Hor+g*sin(2*pi*f*(t-t1)+phi);
>   > > 
>   > > error=LastValue(Cum(abs(y-new1)));
>   > > 
>   > > if(error<error00)
>   > > 
>   > > {error00=error;per01=per;g01=g;phi01=phi;}
>   > > 
>   > > }}}
>   > > 
>   > > f01=1/per01;y01=Hor+g01*sin(2*pi*f01*(t-t1)+phi01); 
>   > > 
>   > > Plot(y01+yy,"y01",colorSkyblue,4);
>   > > 
>   > > Title=Name()+" [ Sample="+WriteVal(Daysback,1.0)+" 
>   > bars ]"+"\nyS0="+WriteVal(Hor,1.2)+
>   > > 
>   > > "\nyS01="+
>   > > 
>   > > WriteVal(g01,1.1)+"*sin(2*pi*(1/"+
>   > > 
>   > > WriteVal(per01,1.0)+")*(t-t1)+"+
>   > > 
>   > > WriteVal(12*phi01/pi,1.0)+"*pi/"+WriteVal(n, 1.0)+"), 
>   > Error1 ="+
>   > > 
>   > > WriteVal(LastValue(Cum(abs(y01-new1))),1.0)+", Error1/bar 
>   > ="+
>   > > 
>   > > WriteVal(2*LastValue(Cum(abs(y01-new1)))/Daysback,1.2)+" 
>   > %";;
>   > > 
>   > > // Fundamental period, detailed approximation
>   > > 
>   > > error0=10000;per1=0;g1=0;phi1=0;stg=0.5;stp=10;
>   > > 
>   > > for(phi=0;phi<2*pi;phi=phi+pi/n)
>   > > 
>   > > {
>   > > 
>   > > for(g=0.5;g<=8;g=g+stg)
>   > > 
>   > > {
>   > > 
>   > > for(per=per01-stp0;per<=per01+stp0;per=per+stp) 
>   > > 
>   > > {f=1/per;
>   > > 
>   > > y=Hor+g*sin(2*pi*f*(t-t1)+phi);
>   > > 
>   > > error=LastValue(Cum(abs(y-new1)));
>   > > 
>   > > if(error<error0)
>   > > 
>   > > {error0=error;per1=per;g1=g;phi1=phi;}
>   > > 
>   > > }}}
>   > > 
>   > > f1=1/per1;y1=Hor+g1*sin(2*pi*f1*(t-t1)+phi1); 
>   > > 
>   > > Plot(y1+yy,"y1",colorBlue,4);
>   > > 
>   > > Title=Title+
>   > > 
>   > > "\nyS1="+
>   > > 
>   > > WriteVal(g1,1.1)+"*sin(2*pi*(1/"+
>   > > 
>   > > WriteVal(per1,1.0)+")*(t-t1)+"+
>   > > 
>   > > WriteVal(12*phi1/pi, 1.0)+"*pi/"+WriteVal(n,1.0)+"), 
>   > Error1 ="+
>   > > 
>   > > WriteVal(LastValue(Cum(abs(y1-new1))),1.0)+", Error1/bar 
>   > ="+
>   > > 
>   > > WriteVal(2*LastValue(Cum(abs(y1-new1)))/Daysback,1.2)+" 
>   > %";;
>   > > 
>   > > // 2nd Harmonic
>   > > 
>   > > error0=10000;
>   > > 
>   > > for(phi=0;phi<2*pi;phi=phi+pi/n)
>   > > 
>   > > {
>   > > 
>   > > for(g=0;g<=8;g=g+0.1)
>   > > 
>   > > {
>   > > 
>   > > per2=per1/2;f=1/per2;
>   > > 
>   > > y2=y1+g*sin(2*pi*f*(t-t1)+phi);
>   > > 
>   > > error2=LastValue(Cum(abs(y2-new1))); 
>   > > 
>   > > if(error2<error0)
>   > > 
>   > > {error0=error2;g2=g;phi2=phi;}
>   > > 
>   > > }}
>   > > 
>   > > f2=1/per2;y2=y1+g2*sin(2*pi*f2*(t-t1)+phi2);
>   > > 
>   > > Plot(y2+yy,"y1",colorYellow,8);
>   > > 
>   > > Title=Title+
>   > > 
>   > > "\nyS2="+ 
>   > > 
>   > > WriteVal(g2,1.1)+"*sin(2*pi*(1/"+
>   > > 
>   > > WriteVal(per2,1.0)+")*(t-t1)+"+
>   > > 
>   > > WriteVal(12*phi2/pi,1.0)+"*pi/"+WriteVal(n,1.0)+"), 
>   > Error2 ="+
>   > > 
>   > > WriteVal(LastValue(Cum(abs(y2-new1))),1.0)+", Error2/bar 
>   > ="+
>   > > 
>   > > WriteVal(2*LastValue(Cum(abs(y2-new1)))/Daysback,1.2)+" 
>   > %";;
>   > > 
>   > > // 3rd Harmonic
>   > > 
>   > > error0=10000;
>   > > 
>   > > for(phi=0;phi<2*pi;phi=phi+pi/n)
>   > > 
>   > > {
>   > > 
>   > > for(g=0;g<=8;g=g+0.1)
>   > > 
>   > > {
>   > > 
>   > > per3=per2/2;f=1/per3;
>   > > 
>   > > y3=y2+g*sin(2*pi*f*(t-t1)+phi);
>   > > 
>   > > error3=LastValue(Cum(abs(y3-new1))); 
>   > > 
>   > > if(error3<error0)
>   > > 
>   > > {error0=error3;g3=g;phi3=phi;}
>   > > 
>   > > }}
>   > > 
>   > > f3=1/per3;y3=y2+g3*sin(2*pi*f3*(t-t1)+phi3);
>   > > 
>   > > Plot(y3+yy,"y1",colorWhite,8);
>   > > 
>   > > Title=Title+
>   > > 
>   > > "\nyS3="+ 
>   > > 
>   > > WriteVal(g3,1.1)+"*sin(2*pi*(1/"+
>   > > 
>   > > WriteVal(per3,1.0)+")*(t-t1)+"+
>   > > 
>   > > WriteVal(12*phi3/pi,1.0)+"*pi/"+WriteVal(n,1.0)+"), 
>   > Error3 ="+
>   > > 
>   > > WriteVal(LastValue(Cum(abs(y3-new1))),1.0)+", Error3/bar 
>   > ="+
>   > > 
>   > > WriteVal(2*LastValue(Cum(abs(y3-new1)))/Daysback,1.2)+" 
>   > %";
>   > > 
>   > > /*
>   > > 
>   > > ===============================
>   > > 
>   > > 
>   > > 
>   > > On 9/5/06, Ton Sieverding <ton.sieverding@> wrote: 
>   > > I certainly like what I see Fred. But do you have the 
>   > AFL code for this picture also ?
>   > > Is this based on Fourier stuff ? I have tried to find 
>   > the FTT instructions in AFL but cannot find them. Do they 
exist 
>   in 
>   > AFL or did you use some special DLL ?
>   > > 
>   > > Kind regards,
>   > > Ton Sieverding.
>   > > 
>   > > ----- Original Message ----- 
>   > > From: Fred Tonetti 
>   > > To: [email protected] 
>   > > Sent: Tuesday, September 05, 2006 6:18 AM
>   > > Subject: [amibroker] Re: Cycles and Mesa
>   > > 
>   > > 
>   > > 
>   > > For example .
>   > > 
>   > > <<...>> 
>   > > 
>   > > 
>   > > 
>   > > ----------------------------------------------------------
>   > > I am using the free version of SPAMfighter for private 
>   > users.
>   > > It has removed 8436 spam emails to date.
>   > > Paying users do not have this message in their emails.
>   > > Try SPAMfighter for free now!
>   > >
>   >
>






Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to