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

RE: [amibroker] Some Math Help Please



PureBytes Links

Trading Reference Links

Thank you Joe, good advice. Unfortunately, I was trying to get Math help rather than AFL help. It has been so long that I studied Trig that I forgot how to calculate the angle of a line.
So for instance, how would I calculate the angle in degrees of a line such as a moving average?
 
thank you
Tom
 
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf Of Joe Landry
Sent: Monday, July 18, 2005 8:27 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Some Math Help Please

AN EXAMPLE:

I don't know why your codes doesn't work but building on what Graham wrote here's a an example (since I had to fight through this at one time)

This is a snippet from one of my indicators is based on Dimitris's work ....BB is the slope of the line at the last bar.  I write it out on the chart

as follows

Title = FullName()+" "+ Date()+"\n"+ "Slope of Regression Line(X1000) = "+ WriteVal(10000*bb);

If  you're new to this script, I'd recommend you take up one of the most productive practices I've found and

adapt for your work.  Find an information database(I use Infoselect)  for your system and clip every interesting indicator or algorithm you 

see used in this forum for your own library.  This of course would be in addition to what Graham recommended 2-3 weeks back...going through each function and using the function in a test program .

Searching the archives 2-3 years back for Graham's and Dimitris Tsokakis' work would also pay off.

Best regards

JOE

 

 

// Plot the slope of the relative strength line

//

Daysback = 126; // 6 months

x = Cum(1); // the X axis, abscissa

LastX = LastValue(X);

C1 = Issue2Rel; // the Y axis, the ordinate

aa = LastValue( LinRegIntercept( C1, Daysback) );

bb = LastValue( LinRegSlope( C1, Daysback ) );

yy = Aa + bb * ( x - (Lastx - DaysBack) ); // the algebraic equation for a straight line

yy=IIf( x >= (lastx - Daysback), yy, -1e10 ); // roll the plot forward and show only the 6 months

Plot( yy, "LinRegression Line", colorDarkRed,styleThick);

UpperSEBand = YY + 2*StdErr(Issue2Rel,126);

LowerSEBand = YY - 2*StdErr(Issue2Rel,126);

Plot(UpperSEBand,"Upper 2 Sigma",colorBlue,styleLine);

Plot(LowerSEband,"Lower 2 Sigma",colorBlue,styleLine);

----- Original Message -----
From: valrox1
Sent: Monday, July 18, 2005 12:36 AM
Subject: [amibroker] Some Math Help Please

I am trying to calculate the angle of a plotted slope in degrees.
Below is the code I thought would work, but doesn't.

Any thoughts?

Thank you
Tom

LSMA = LinearReg(C, 25 );

a=atan(LSMA);

RAD_TO_DEG = 180/3.1415926; // radians to degrees

Angle = RAD_TO_DEG * a; //

Plot( Angle, "LSMA", colorYellow, styleThick);


Title = "Angle=" + Angle +      EncodeColor(colorWhite) + " " + Date
();






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





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software Stock investment software


YAHOO! GROUPS LINKS