PureBytes Links
Trading Reference Links
|
Stephane,
a. What should I do after downloading and save this test.dll [it
b. The fit criterion is the minimum total error.
The only way to express this quantity is to sum the abs(y-C1) for all
bars and then minimize it.[In linear reg, for example, we minimise
the sum of (y-C1)^2]
b1. What is your criterion, if not the minimum of
LastValue(Cum(abs(y-C1)));
b2. Since you already have the equation of your blue line, check if
it gives smaller error to see if it fits better than my white line.
c. LastValue is used many times in my code, before the error
calculation[ in lastx, Daysback, aa, bb, Hor. I did not understand
how do you solve the LastValue in all these cases and where is the
problem in error=LastValue(...) line.
d. In any case, it is reasonable to ask the total error to be
minimum. The error per bar would not make sense. We may have a
function that minimizes the error for the first, say, 500 bars but
not for all bars.
d. I will agree that LastValue(array) is known "before" the last bar.
There is no problem here, I use the results of all the LastValue()s
exactly at the last bar, not before. This way of use does not
introduce any "looking into the future" problem.[A problem, for
example, would be to use a LastValue() result in the middle of an
array and DECIDE for tomorrows movements]
TIA
Dimitris Tsokakis
PS:Stephane's attachements are at
http://www.purebytes.com/archives/amibroker/2004/msg07780.html
--- In amibroker@xxxxxxxxxxxxxxx, "Stephane Carrasset"
<s.carrasset@xxxx> wrote:
> Dimitri,
> I have always some doubt about the usage of lastvalue in afl code
> lastvalue returns the array value of [barcount-1] along all the
bars, so somewhere I ask me if it looks in the future?
> the c++ code does not use lastvalue, of course the sinusoid are
differents , but I don't know which one is more accurate
> attached the two chart on DJI, white ( the dll), blue the afl for
the first // Fundamental period, crude approximation
>
>
>
>
> // 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);
>
> 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",colorBlue,1|styleThick);
>
> /*
>
> you can plot the dll for this first Elementary Fourier analysis with
>
> sft=dtFFT(C1,detrend,t1);
>
> Plot(yy +sft,"sft",colorWhite,1|styleThick);
>
> */
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
---------------------------------------------------------------------~->
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/
|