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

Re: [amibroker] A Profitable Indicator



PureBytes Links

Trading Reference Links




Dimitris,
 
The linear (Least-Squares ) regression model 
postulates that 
Y= a+bX+e
Where the "residual" e is a random variable with mean zero.  
The coefficients a and b are determined by the 
condition that the sum of the square residuals is as small as possible. 

So error is SUM OF THE SQUARE of residuals.
 
You are not using sum of squares of residuals as error estimate.
 
For more info see:
<A 
href="">http://www.stat.yale.edu/Courses/1997-98/101/linreg.htm
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Dimitris 
  Tsokakis 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, March 15, 2004 12:17 
  PM
  Subject: [amibroker] The linear trend 
  calculations
  
  I tried to duplicate the LinRegIntercept( ARRAY, periods ) 
  example from the 4.50 users guide.I used as example the 
  C1=MA(RSI(50),200).The error was calculated from 
  Cum(abs(y-C1)).
   
  C1=MA(RSI(50),200);Plot(C1,"C1",1,1); x = 
  Cum(1);lastx = LastValue( x ); Daysback = 
  LASTX-ValueWhen(Cum(IsTrue(C1))==1,X); aa = LastValue( LinRegIntercept( 
  C1, Daysback) );bb = LastValue( LinRegSlope( C1, Daysback ) );y = Aa + 
  bb * ( x - (Lastx - DaysBack) ); Plot( IIf( x >= (lastx - Daysback), y, 
  -1e10 ), "LinReg", colorRed,8 ); 
  Title=Name()+"\nLine="+WriteVal(aa,1.1)+"+"+WriteVal(bb,1.3)+"*(t-t1)"+"\nError="+WriteVal(Cum(abs(y-C1)),1.0);start=Cum(IsTrue(C1))==1;PlotShapes(shapeUpTriangle*start,colorWhite);
   
  My analytic 
  codet=Cum(1)-1;tmax=LastValue(t);C1=MA(RSI(50),200);Plot(C1,"C1",1,1);C1max=1.5*LastValue(ceil(Highest(C1)));C1min=0.5*LastValue(floor(Lowest(C1)));start=Cum(IsTrue(C1))==1;t1=ValueWhen(start,t);PlotShapes(shapeUpTriangle*start,colorWhite);C10=ValueWhen(start,C1);d0=Param("d0",-0.03,-0.03,-0.005,0.005);Line0=C10+d0*(t-t1);d1=-d0;Line1=C10+d1*(t-t1);Error0=LastValue(Cum(abs(C1-Line0)));Error1=LastValue(Cum(abs(C1-Line1)));Err=Max(Error0,Error1);Title=Name()+"\nInitial 
  Error="+WriteVal(err,1.0);stepi=0.1;stepj=0.001;j1=d1;j0=d0;for(i=C1min;i<=C1max;i=i+stepi){for(j=j0;j<=j1;j=j+stepj){Line=i+j*(t-t1);err1=LastValue(Cum(abs(C1-Line)));if(err1<err)err=Min(err,err1);}}Title=Title+"\nMinError="+WriteVal(err,1.0);iA=0;jA=0;for(i=C1min;i<=C1max;i=i+stepi){for(j=j0;j<=j1;j=j+stepj){Line=i+j*(t-t1);err1=LastValue(Cum(abs(C1-Line)));if(err1==err){Plot(Line,"\n"+WriteVal(j,1.4),colorRed,8);Title=Title+"\n\nLine="+WriteVal(i,1.1)+"+"+WriteVal(j,1.3)+"*(t-t1)";iA=i;jA=j;}}}Title=Title+"\nFirst 
  Approx [iA,jA]=["+WriteVal(iA,1.1)+","+WriteVal(jA,1.3)+"]";
   
  gave, in many cases, smaller error.Is there any 
  explanation ?Dimitris Tsokakis
   
   Send 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 
  


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.