Johan After taking the time to put that long winded explanation together, I finally realized why the end value on my Volatility Check plot isn't equal to the end value for your Volatility calculation (i think). Sorry for being such a knucklehead - and thanks again for the code.
Final exploration is forthcoming. Tim --- In [email protected], Tim Gadd <[EMAIL PROTECTED]> wrote: > > Thanks for staying with me, Johan : ) > > Just to make sure we are "on the same page", let me > use an example. First, I'll re-insert your code here > ... > > //////////////////////////////////////////////////////////////////// /////// > Periods = 40; > > end = LinearReg( C, periods ); > start = LinRegIntercept( C, periods ); > slope = LinRegSlope( C, periods ); > > for( n = x = 0; n < periods; n++ ) > x = x + abs( Ref( C, - n ) - ( end - n * slope ) ); > > Direction = end - start; > Volatility = x; > ER = (Direction / Volatility); > //////////////////////////////////////////////////////////////////// /////// > > If I insert a "static" 40-period linear regression > channel drawing object (with a start date of 16Feb06 > and end date of 13Apr06) on the price of symbol SPY, > the end point (the 40th point) on the linear > regression line has a y value of 130.056. If I use the > code Plot(LinearReg(Close, 40),"", colorBlack, > styleLine) on the same chart, the end value for this > "moving" linear regression line (the same as your > "end" variable) is also 130.056. Other values along > the 2 plots will probably not be the same, of course. > > It is along the "static" linear regression line that I > want to compute the Efficiency Ratio. At the last/40th > point, the value for scatter = abs(Close - 40th_y) = > abs(Close - end) = abs(128.71 - 130.056) = 1.346. I'm > not using proper AFL here, of course, but i'm trying > to convey my thinking in my own ignorant way. At the > 39th point along the 40-period linear regression line, > the value for scatter would be abs(Close - 39th_y). I > want to calculate this value for scatter (the absolute > value of the difference between each day's closing > price and the y value on that static linear regression > line) and then sum the 40 values for scatter to get > the value for Volatility (the denominator in the ER > calculation). > > In essence, what I want to do is look at a x-period > segment of various price plots and compare the > volatility-adjusted rate of change of each by > measuring the rate of change along the x-period linear > regression line and the scatter along this line. > Again, i know there are other ways that i might do it, > but this is an approach i wanted to look at, but don't > begin to know how to code. > > tia for your (or any one else's) help. > > Tim > > --- johsun <[EMAIL PROTECTED]> wrote: > > > No, because in this case end will be a different > > value for each of > > the bars in the lookback period; a new endpoint of a > > different > > regression line. You want to calculate the > > difference between the > > previous 40 closes and the current bars 40-bar > > regline. Hope I'm > > making sense;) > > > > Johan > > > > > > > > --- In [email protected], "timgadd" > > <timgadd@> wrote: > > > > > > Johan, > > > > > > I may have been over-enthusiastic in thinking that > > your code > > worked > > > as I had planned. The numerator (Direction) is > > fine. I'm not sure > > > that the denominator (Volatility) is working as > > planned. It's > > > definitely close. > > > > > > Assuming that the calculation for the "scatter" at > > the last point > > on > > > the linear regression line should be abs(Close - > > End), shouldn't > > the > > > following line return the same value for > > "Volatility" (the sum of > > the > > > scatter) at the last/end point? > > > > > > AddColumn(Sum(abs(Close-end),40),"Volatility > > Check"); > > > > > > > > > > > > > > > > > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > 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: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
