For example ...

SVBI   = SelectedValue(BarIndex());
DFTLen = 200;

if (DFTLen > SVBI)
    DFTLen = SVBI;

pi     = 4 * atan(1);

Ax = C;

Coeffs = int(DFTLen / 2);

Coeffn = LengXn = RealXn = ImagXn = AmplXn = PhasXn = Cum(0);

for (Coeff = 0; Coeff <= Coeffs; Coeff++)
{
    RealX  = Sum( Ax * cos(2 * pi * Coeff * BarIndex() / DFTLen), 
DFTLen);
    ImagX  = Sum(-Ax * sin(2 * pi * Coeff * BarIndex() / DFTLen), 
DFTLen);

    Coeffn[Coeff] = Coeff;
    LengXn[Coeff] = DFTLen / Coeff;
    RealXn[Coeff] = SelectedValue(RealX);
    ImagXn[Coeff] = SelectedValue(ImagX);
    AmplXn[Coeff] = (RealXn[Coeff] ^ 2 + ImagXn[Coeff] ^ 2) ^ 0.5;
    if (RealXn[Coeff] == 0)
        if (ImagXn[Coeff] > 0)
            PhasXn[Coeff] =  pi / 2;
        else
            PhasXn[Coeff] = -pi / 2;
    else
    {
        PhasXn[Coeff] = atan(ImagXn[Coeff] / RealXn[Coeff]);
        if (RealXn[Coeff] < 0)
            if (ImagXn[Coeff] < 0)
                PhasXn[Coeff] = PhasXn[Coeff] - pi;
            else
                PhasXn[Coeff] = PhasXn[Coeff] + pi;
    }
}

Filter = BarIndex() >= 1 AND BarIndex() <= Coeffs;

AddColumn(BarIndex(), "Coeff",  1.0);
AddColumn(LengXn,     "Length", 1.5);
AddColumn(RealXn,     "Real",   1.9);
AddColumn(ImagXn,     "Imag",   1.9);
AddColumn(AmplXn,     "Ampl",   1.5);
AddColumn(PhasXn,     "Phase",  1.9);

--- In [email protected], "wavemechanic" <[EMAIL PROTECTED]> wrote:
>
> Here is a link to a summary of FFT/DFT that might be useful 
(http://www.dataq.com/applicat/articles/an11.htm)
> 
> Bill
> 
> 
> ----- Original Message ----- 
> From: "Fred" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Friday, October 06, 2006 10:47 AM
> Subject: [amibroker] Re: Polynomial Trendlines
> 
> 
> > TJ,
> > 
> > I have long since had FFT capability in AFL as the algorithms 
are 
> > very straight forward and relatively simple to do in AFL.  
However 
> > FFT's typically require LOTS of data relative to the cycle 
lengths 
> > one is attempting to identify and do not provide particularly 
good 
> > resolution at the lower frequencies.  From this perspective 
tools 
> > like MESA ( The algortihm, NOT the black box product ) provide 
much 
> > greater resolution with much less data.
> > 
> > However, neither of these approaches is what I'm after at this 
> > juncture ... What I'm after is the ability to do trigonometric 
curve 
> > fitting in a similar way to what the PolyFit AFL I posted 
performs 
> > linear curve fitting i.e. via the solution of simultaneous 
> > equations.  This involves some rather sophisticated ( at least 
from 
> > my perspective ) math which can be found for example in Appendix 
6 
> > of J.M. Hurst's book.  Since the discussion there is only about 
3 
> > pages I'd be happy to post it or email it to anyone who has an 
> > interest and is so inclined if they'd like to read it and 
comment on 
> > how to implement it.
> > 
> > Fred
> > 
> > PS ... Some final thoughts about FFT's and their implementation 
in 
> > AB ... If you are going to provide this capability, please do so 
in 
> > a manner that one can take advantage of ALL the information that 
> > would be the product of performing an FFT i.e. both the real & 
> > imaginary arrays or a single array of complex numbers and the 
> > ability to deal with complex numbers in AFL.  This is needed not 
> > only to get amplitudes at particular frequencies but also phase 
> > shift and power.
> > 
> > PPS ... IMHO a DFT type implementation that does not require the 
> > data being anaylized to be a power of 2 in length would be 
superior 
> > to a Cooley-Tukey implementation even if run time is a little 
> > longer ...
> > 
> > --- In [email protected], "Tomasz Janeczko" <groups@> 
> > wrote:
> >>
> >> For that you need Fourier transform and FFT is coming as a 
built 
> > in function in 4.86
> >> 
> >> Best regards,
> >> Tomasz Janeczko
> >> amibroker.com








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