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

[amibroker] Re: Daily Pivots from intraday chart



PureBytes Links

Trading Reference Links

Stephane,
After a detailed exploration, for the specific C1=MA(RSI(50),100); 
g1<8, g2<g1 and g3<2. This can reduce the execution time with

t=Cum(1)-1;
C1=MA(RSI(50),100);
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;
//1stA
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",colorBlack,1);
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)+" %";;*/
//1stB
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",colorYellow,1);
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
error0=10000;
for(phi=0;phi<2*pi;phi=phi+pi/n)
{
for(g=0;g<=g1;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",colorBlue,1);
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
error0=10000;
for(phi=0;phi<2*pi;phi=phi+pi/n)
{
for(g=0;g<=2;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)+" %";;
Plot(new1-y3,"error",3,2+styleOwnScale);

It takes 8sec [PIII/800MHz/64MB RAM] for a stock history of 1100 bars.
It is not bad at all but if we can make it shorter it would be more 
interesting, we could add more sinusoidal summands.
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) 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
>   > > 
>   > >   http://groups.yahoo.com/group/amibroker/files/Elementary%
>   > 20Fourier%20Analysis/fourier1.txt 
>   > > 
>   > >   To learn more about file sharing for your group, please 
visit
>   > > 
>   > >   http://help.yahoo.com/help/us/groups/files
>   > > 
>   > >   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: 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
>   > > 
>   > >     a.. To visit your group on the web, go to:
>   > >     http://groups.yahoo.com/group/amibroker/
>   > >       
>   > >     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.
>   > >   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: 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
> 
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/amibroker/
>       
>     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.
>   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 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:
     http://docs.yahoo.com/info/terms/