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

Re: [amibroker] Some Math Help Please



PureBytes Links

Trading Reference Links

for you ema line you ahve added b=atan(LinRegSlope(EMA34,3)); so you
are actually calculating the lope of the linear regression line of the
EMA line. If you want to find the slope of the EMA line itself, use
the straightforward point1-point2 calculation. Now this becomes ideas
only but you need to scale by the X and Y axis to the extent of
looking at the number of bars on screen and the range of price.

I have a plot on my screen
Plot(C,"close",colorWhite,styleLine);
scale = (1.68-1.32)/(3805-3742); // assume full screen diagonal is 45
degree and manually put in from looking at the screen ( Y-axis range /
X-axis range)
// you can get these values automatically using Status function
Plot( atan((C-Ref(C,-1))/scale)*180/3.142, "angle", colorRed,
styleLine|styleLeftAxisScale );

this gave me a value of angle of -41degree which is close to what it
looked like on screen
To get the slope of the line as you see it on screen, you would need
top add in scaling factors to overcopme the actual values you are
using

On 7/21/05, mymail <grpmail@xxxxxxxxxxxxxxxx> wrote:
> Graham,
>  
> I am trying to determine the angle of the Linereg and Ema lines at a
> particular point in time. For instance, if you draw a 90 degree horizontal
> and vertical line and the Linereg comes through the intersection of that 90
> degree, what angle is the linereg relative to the 90 degree base. If I could
> include an image I could probably express it a little better.
>  
> |
> |
> |
> |
> |    /
> |  /  need the angle of this.
> |/_____________________
>  
> Thank you
> Tom
>  
>  
>  
>  
>  
>  
> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf
> Of Graham
> Sent: Wednesday, July 20, 2005 6:15 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: [amibroker] Some Math Help Please
> 
> In what way are you getting wrong numbers?
> Are you wanting the angle of the linreg line?
> 
> The results look ok to me after plotting.  
> 
> You have to remember that slope is an arbitrary number in charts. You
> must calculate it to suit the scaling factors that affect it if you
> want to gtet the answer similar to what you see on the screen. The
> screen drawn angle will change as you zoom in/out of the chart and may
> possibly be the same as calculated figure if yuo get lucky.
> I have stated this before some time ago, angle means absolutely
> nothing by itself as you have no reference in which to base it.
> 
> 
> 
> 
> On 7/21/05, mymail <grpmail@xxxxxxxxxxxxxxxx> wrote:
> > Graham,
> >  
> > I read the thread as it went on. Unfortunately, I am doing something
> wrong,
> > as I am not getting the correct numbers.
> >  
> > Here is my code snippet. Did I miss something obvious?
> >  
> > 
> > 
> > LSMA = LinearReg(C, 25 ); 
> > 
> > EMA34 = EMA(C,34); 
> > 
> > a=atan(LinRegSlope(LSMA,3)); 
> > 
> > b=atan(LinRegSlope(EMA34,3)); 
> > 
> > RAD_TO_DEG = 180/3.1415926; // radians to degrees 
> > 
> > Angle = RAD_TO_DEG * a; 
> > 
> > Angle1 = RAD_TO_DEG * b; 
> > 
> > "LSMA ANGLE IS: "+ WriteVal(Angle); 
> > 
> > "EMA34 ANGLE IS: "+ WriteVal(Angle1);
> >  
> > -----Original Message-----
> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On
> Behalf
> > Of Graham
> > Sent: Wednesday, July 20, 2005 5:44 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: Re: [amibroker] Some Math Help Please
> > 
> > just had that discussion here this week re slopes calculation
> > 
> > slope = (value2 - value1) / (bar2 - bar1);
> > angle_rad = atan(slope);//radians
> > angle_deg = angle_rad * 180/3.1416;//degrees
> > 
> > On 7/21/05, mymail <grpmail@xxxxxxxxxxxxxxxx> wrote:
> > > 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 
> > > To: amibroker@xxxxxxxxxxxxxxx 
> > > 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 
> > > 
> > >  Visit your group "amibroker" on the web.
> > >   
> > >  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. 
> > >  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. 
> > >  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
> > > ________________________________
> > > 
> > 
> > 
> > -- 
> > Cheers
> > Graham
> > http://e-wire.net.au/~eb_kavan/
> > 
> > 
> > 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
> > 
> > 
> > 
> > 
> > ________________________________
> > YAHOO! GROUPS LINKS 
> > 
> >  Visit your group "amibroker" on the web.
> >   
> >  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. 
> >  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. 
> >  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
> > ________________________________
> > 
> 
> 
> -- 
> Cheers
> Graham
> http://e-wire.net.au/~eb_kavan/
> 
> 
> 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
> 
> 
> 
> 
> ________________________________
> YAHOO! GROUPS LINKS 
> 
>  Visit your group "amibroker" on the web.
>   
>  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. 
>  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. 
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
> ________________________________
> 


-- 
Cheers
Graham
http://e-wire.net.au/~eb_kavan/


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/DldnlA/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

 
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/