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

Re: [amibroker] Comparing Timing Signals



PureBytes Links

Trading Reference Links




Oh if a c++ guru may have a look I am a poor c++ 
users
 
stephane
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=s.carrasset@xxxxxxxxxxx 
  href="">Stephane Carrasset 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Friday, May 14, 2004 6:05 PM
  Subject: Re: [amibroker] Re: DTFFT
  
  Hello, dimitri,
   
  my first try to translate your SFT code in c++ is 
  a "half success", I have just written the first part, and the code runs 
  faster, BUT...
  the results is different because I am stopped 
  with Lastvalue in
  
  error=<FONT face="Courier New" 
  color=#0000ff>LastValue(Cum(<FONT 
  color=#0000ff>abs(y-new1)));
  The c++ code returns a different error for each bar 
  of a ticker, and the Afl code returns the same value --> the lastvalue 
  -->the value at (nSize-1) or <FONT 
  size=1>(BarCount-1)<FONT 
  size=1>
   
   
  attached, the workspace, the dll ( in release) 
  ,the afl code
   
  //////////////////////////////////// FFT 
  DT/////////////////////////////////
   
  // Elementary Fourier analysis, by D. Tsokakis, 
  May 2004// t=Cum(1)-1;// C1=MA(RSI(50),100);// 
  start=Cum(IsTrue(C1))==1;// t1=ValueWhen(start,t);// 
  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 );// // detrend=C1-yy;// new1=detrend;// 
  Hor=LastValue(Cum(new1)/Cum(IsTrue(C1)));// 
pi=4*atan(1);n=12;
   
  AmiVar FFTDT( int NumArgs, AmiVar *ArgsTable 
  ){
   
   int i; int nSize = 
  gSite.GetArraySize(); AmiVar IstruepPrice = 
  gSite.AllocArrayResult(); AmiVar Hor = 
  gSite.AllocArrayResult(); AmiVar y01 = 
  gSite.AllocArrayResult(); AmiVar y = 
  gSite.AllocArrayResult(); AmiVar error = 
  gSite.AllocArrayResult(); AmiVar Lv_error = 
  gSite.AllocArrayResult();
   
   float*pPrice=ArgsTable[ 0 
  ].array; float*Detrend=ArgsTable[ 1 
  ].array; float*t1=ArgsTable[ 2 ].array;
   
  ISTRUE (pPrice,IstruepPrice);
   
   AmiVar arg[ 1 ]; arg[ 0 ].type = 
  VAR_ARRAY; arg[ 0 ].array = IstruepPrice.array;  AmiVar 
  CumC1 = gSite.CallFunction( "CUM", 1, arg );
   
   AmiVar arg1[ 1 ]; arg1[ 0 ].type = 
  VAR_ARRAY; arg1[ 0 ].array = Detrend;  AmiVar CumDetrend = 
  gSite.CallFunction( "CUM", 1, arg1 );
   
  for( i=0;i<nSize;i++){// 
  Hor=LastValue(Cum(Detrend)/Cum(IsTrue(C1)));Hor.array[i]= 
  CumDetrend.array[i] / CumC1.array[i];}
   
  float cumHor = Hor.array[nSize-1];
   
  // // 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);
   
  double error00=10000;float per01=0.0;float 
  g01=0.0;double phi01=0.0;float stg0=0.5;float stp0=100;int 
  n=12;
   
  // double* y = new double[nSize];// double* Error = 
  new double[nSize];
   
  for(i=0;i<nSize;i++){ if( 
  t1[i]==EMPTY_VAL) {  y.array[i]=EMPTY_VAL;  y01.array[i]=EMPTY_VAL;  continue; }
   
   for(double 
  phi=0;phi<2*PI;phi=phi+PI/n) {  for(float 
  g=0.5;g<=8;g=g+stg0)  {   for(float 
  per=300;per<=1000;per=per+stp0)   {    float 
  f=1/per;    y.array[i]=(float)(cumHor + 
  g*sin(2*PI*f*(i-t1[i])+phi));
   
      error.array[i]=(float) 
  (error.array[i-1] + fabs(y.array[i]-Detrend[i]));
   
  <FONT 
  size=2>    if(error.array[i]<error00)    {     error00=error.array[i];per01=per;g01=g;phi01=phi;    }   }  } }float 
  f01=1/per01;y01.array[i]= (float) (Hor.array[i] + 
  g01*sin(2*PI*f01*(i-t1[i])+phi01));}
   
  //  delete[] y;//  delete[] 
error;
   
  float Error= 
  error.array[nSize-1];for(i=0;i<nSize;i++){Lv_error.array[i]=Error;}
   
  gSite.SetVariable( "dty", y );gSite.SetVariable( 
  "dterror", error );gSite.SetVariable( "dtLverror", Lv_error 
  );gSite.SetVariable( "dtHor", Hor);return y01;
   
  }
  <BLOCKQUOTE 
  >
    ----- Original Message ----- 
    <DIV 
    >From: 
    DIMITRIS 
    TSOKAKIS 
    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">amibroker@xxxxxxxxxxxxxxx 
    Sent: Friday, May 14, 2004 6:43 
AM
    Subject: [amibroker] Re: DTFFT
    Stephane,It is the 
    total [cumulative] error that should be minimum.The idea of this 
    Elementary Fourier Analysis [let us use EFA instead of FFT, because FFT 
    concept is a bit different...] refers to the whole history of the 
    oscillator.Another procedure would be the Sum(error,per) to reflect the 
    last per days, but not for this moment.If we have a faster code, we 
    could add more sinusoidal summands and drop the error below 
    1%.[!!]Dimitris Tsokakis--- In amibroker@xxxxxxxxxxxxxxx, "Stephane 
    Carrasset" <s.carrasset@xxxx> wrote:> Dimitri,> 
    > is it really important to keep lastvalue in> 
    error=LastValue(Cum(abs(y-detrend)));> > because  in c++ 
    I can write the code without lastvalue, but of course the result s 
    different> > stephane> >   ----- 
    Original Message ----- >   From: DIMITRIS TSOKAKIS 
    >   To: amibroker@xxxxxxxxxxxxxxx >   
    Sent: Thursday, May 13, 2004 9:42 AM>   Subject: 
    [amibroker] Re: New file uploaded to amibroker> > 
    >   Stephane,>   you may see now the 
    comparison of my AFL Elementary Fourier analysis >   
    and the usual FFT. There is a significant error decreament but, the 
    >   most important, a much better fundamental period 
    approximation.>   The sample was 921 bars of the Nikkei 
    C1=MA(RSI(50),100); and the FFT >   analysis was 
    executed in DaDisp_SE2000.>   Any suggestion to make my 
    analysis faster would improve the >   sinusoidal 
    approximation and would give an interesting T/A tool>   
    Dimitris Tsokakis>   --- In amibroker@xxxxxxxxxxxxxxx, 
    "Stephane Carrasset" >   <s.carrasset@xxxx> 
    wrote:>   > Dimitri, Perhaps I'll try to translate it in 
    c++ (this WE) to get >   it 
    faster...>   > But as I see you turn to be a master in 
    looping>   > I think you must have a look to c++ 
    programming with ADK because >   there is a math world 
    that I would like to explore ( Adaptive >   simulated 
    annealing) <FONT 
    size=2>http://www.ingber.com>   
    > >   > >   > 
    stephane>   >   ----- Original Message ----- 
    >   >   From: DIMITRIS TSOKAKIS 
    >   >   To: amibroker@xxxxxxxxxxxxxxx 
    >   >   Sent: Thursday, May 06, 2004 9:47 
    PM>   >   Subject: [amibroker] Re: New file 
    uploaded to amibroker>   > >   > 
    >   >   Note also, to avoid any confusion, 
    that it is pure sinusoidal >   >   analysis 
    and has nothing to do with FFT, the 512 or 1024 or 2^n 
    >   >   points, the well known end point 
    problems etc.>   >   I believe the sinusoidal 
    trend gives interesting info in >   combination 
    >   >   with the [available in AFL syntax] 
    linear trend.>   >   Dimitris 
    Tsokakis>   >   --- In 
    amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" >   
    <TSOKAKIS@xxxx> >   >   
    wrote:>   >   > 
    Stephane,>   >   > Any ideas to make it 
    shorter will be much appreciated !!>   >   
    > We should *do* something instead of waiting and waiting [and I 
    >   hope >   >   > you 
    agree...]>   >   > Dimitris 
    Tsokakis>   >   > --- In 
    amibroker@xxxxxxxxxxxxxxx, "Stephane Carrasset" >   
    >   > <s.carrasset@xxxx> wrote:>   
    >   > > Ouah!!>   >   > 
    > Dimitri, don't know how many loops you have written, it takes 
    >   at >   >   > least 2 
    minutes to be plotted on my "old" computer...>   
    >   > > it seems here we find an usage of 
    c++>   >   > > >   
    >   > > stephane>   >   
    > >   ----- Original Message ----- >   
    >   > >   From: amibroker@xxxxxxxxxxxxxxx 
    >   >   > >   To: 
    amibroker@xxxxxxxxxxxxxxx >   >   > 
    >   Sent: Thursday, May 06, 2004 9:48 AM>   
    >   > >   Subject: [amibroker] New file 
    uploaded to amibroker>   >   > > 
    >   >   > > >   
    >   > > >   >   > 
    >   Hello,>   >   > > 
    >   >   > >   This email 
    message is a notification to let you know that>   
    >   > >   a file has been uploaded to the Files 
    area of the amibroker >   >   > 
    >   group.>   >   > > 
    >   >   > >     
    File        : /Elementary Fourier 
    Analysis/fourier1.txt >   >   > 
    >     Uploaded by : dtsokakis <TSOKAKIS@xxxx> 
    >   >   > >     
    Description :  >   >   > > 
    >   >   > >   You can access 
    this file at the URL>   >   > > 
    >   >   > >   <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amibroker/files/Elementary%<FONT 
    size=2>>   >   > 
    20Fourier%20Analysis/fourier1.txt >   >   > 
    > >   >   > >   To learn 
    more about file sharing for your group, please >   
    visit>   >   > > >   
    >   > >   <A 
    href=""><FONT 
    size=2>http://help.yahoo.com/help/us/groups/files<FONT 
    size=2>>   >   > > >   
    >   > >   Regards,>   
    >   > > >   >   > 
    >   dtsokakis <TSOKAKIS@xxxx>>   
    >   > > >   >   > > 
    >   >   > > >   
    >   > > >   >   > > 
    >   >   > > >   
    >   > >   Send BUG REPORTS to 
    bugs@xxxx>   >   > >   Send 
    SUGGESTIONS to suggest@xxxx>   >   > 
    >   
    ----------------------------------------->   
    >   > >   Post AmiQuote-related messages ONLY 
    to: >   >   amiquote@xxxxxxxxxxxxxxx 
    >   >   > >   (Web page: 
    <FONT 
    size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
    size=2>>   >   > >   
    -------------------------------------------->   
    >   > >   Check group FAQ at: 
    >   >   > <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
    size=2> >   >   > > >   
    >   > > >   >   > 
    >         Yahoo! Groups Sponsor 
    >   >   > 
    >               
    ADVERTISEMENT>   >   > 
    >              
    >   >   > 
    >        >   
    >   > >        
    >   >   > > >   
    >   > > >   >   > > 
    -------------------------------------------------------------->   
    ---->   >   -->   
    >   > ---------->   >   > 
    >   Yahoo! Groups Links>   >   
    > > >   >   > 
    >     a.. To visit your group on the web, go 
    to:>   >   > >     
    <FONT 
    size=2>http://groups.yahoo.com/group/amibroker/<FONT 
    size=2>>   >   > 
    >       >   
    >   > >     b.. To unsubscribe from 
    this group, send an email to:>   >   > 
    >     
    amibroker-unsubscribe@xxxxxxxxxxxxxxx>   >   
    > >       >   
    >   > >     c.. Your use of Yahoo! 
    Groups is subject to the Yahoo! >   Terms 
    >   >   of >   
    >   > Service. >   >   > 
    > >   >   > > >   
    >   > > >   >   > 
    >   __________ NOD32 1.751 (20040505) Information 
    __________>   >   > > 
    >   >   > >   This message was 
    checked by NOD32 antivirus system.>   >   > 
    >   <FONT 
    size=2>http://www.nod32.com>   > 
    >   > >   > >   
    >   Send BUG REPORTS to bugs@xxxx>   
    >   Send SUGGESTIONS to suggest@xxxx>   
    >   
    ----------------------------------------->   
    >   Post AmiQuote-related messages ONLY to: 
    amiquote@xxxxxxxxxxxxxxx >   >   (Web 
    page: <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
    size=2>>   >   
    -------------------------------------------->   
    >   Check group FAQ at: >   <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
    size=2> >   > >   > 
    >   >         
    Yahoo! Groups Sponsor >   
    >               
    ADVERTISEMENT>   
    >              
    >   >        
    >   >        
    >   > >   > >   
    > 
    -------------------------------------------------------------------->   
    ---------->   >   Yahoo! Groups 
    Links>   > >   
    >     a.. To visit your group on the web, go 
    to:>   >     <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amibroker/<FONT 
    size=2>>   >       
    >   >     b.. To unsubscribe from 
    this group, send an email to:>   
    >     
    amibroker-unsubscribe@xxxxxxxxxxxxxxx>   
    >       >   
    >     c.. Your use of Yahoo! Groups is subject to the 
    Yahoo! Terms of >   Service. >   > 
    >   > >   > >   
    >   __________ NOD32 1.751 (20040505) Information 
    __________>   > >   >   
    This message was checked by NOD32 antivirus system.>   
    >   <FONT 
    size=2>http://www.nod32.com> > 
    > >   Send BUG REPORTS to 
    bugs@xxxx>   Send SUGGESTIONS to 
    suggest@xxxx>   
    ----------------------------------------->   Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
    >   (Web page: <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
    size=2>>   
    -------------------------------------------->   Check group 
    FAQ at: <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
    size=2> > > > > 
    ------------------------------------------------------------------------------>   
    Yahoo! Groups Links> >     a.. To visit 
    your group on the web, go to:>     <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amibroker/<FONT 
    size=2>>       
    >     b.. To unsubscribe from this group, send an 
    email to:>     
    amibroker-unsubscribe@xxxxxxxxxxxxxxx>       
    >     c.. Your use of Yahoo! Groups is subject to 
    the Yahoo! Terms of Service. > > > 
    >   __________ NOD32 1.756 (20040511) Information 
    __________> >   This message was checked by NOD32 
    antivirus system.>   <A 
    href=""><FONT 
    size=2>http://www.nod32.com<FONT 
    size=2>Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <FONT 
    size=2>http://groups.yahoo.com/group/amiquote/messages/)<FONT 
    size=2>--------------------------------------------Check group FAQ at: 
    <A 
    href=""><FONT 
    size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
    size=2> __________ NOD32 1.756 (20040511) 
    Information __________This message was checked by NOD32 antivirus 
    system.<FONT 
    size=2>http://www.nod32.comSend BUG 
  REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  __________ 
  NOD32 1.756 (20040511) Information __________This message was checked 
  by NOD32 antivirus system.<A 
  href="">http://www.nod32.com


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Sponsor


  ADVERTISEMENT 












Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.