You can use lastvalue if you are testing to the last bar of the chart,
otherwise if you want to do this over a range within the chart history
you can use status to find the first and last values for that range
for use in analysis window it will take the date range as used. I have
also added lastvalue so that it will always give these values even
during the range
first = lastvalue( valuewhen( status("firstbarinrange"), Sum(Abs(C -
LinearReg(C, periods)), periods) ) );
last = lastvalue( valuewhen( status("lastbarinrange"), Sum(Abs(C -
LinearReg(C, periods)), periods) ) );
if you want this in a chart then you can use the range markers (mouse
double click gives the lines with triangles at bottom) and beginvalue
and endvalue functions
--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm
On 4/15/06, timgadd <[EMAIL PROTECTED]> wrote:
> I'd like to employ a variation of Kaufman's Efficiency Ratio to help
> screen for stocks in tight rising channels. Specifically, I'd like to
> compare a stock's ROC weighted by it's Efficiency Ratio to that of a
> market index to screen out stocks that are outperforming the index on
> a volatiliy adjusted basis. (I realize there are other ways to
> approach this, but I'd like to try this approach).
>
> The standard version of the Efficiency Ratio is defined as the
> absolute value of direction over volatility where ...
>
> Direction = C - Ref(C, -periods);
> Volatility = Sum(Abs(ROC(C,1), periods);
>
> I'd like, instead, to define Direction as the last (y) value of a
> static (non-moving) linear regression line minus the first (y) value
> of the static linear regression line.
>
> I'd like to define Volatility as the "scatter" at each point along
> the static linear regression line ... something like ...
>
> Sum(Abs(C - LinearReg(C, periods)), periods);
>
> ... except that this uses the moving linear regression calculation.
> I'd like to keep the start point of the regression line constant so
> that I can measure the efficiency ratio from a static reference point
> (a technical low).
>
> I've stumbled through some code for a static linear regression line
> (link below), but cannot figure our how to determine the beginning
> and ending points.
>
> http://www.amibroker.com/library/detail.php?id=193&hilite=LASTVALUE
>
> Any suggestions?
>
>
>
>
>
> 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
>
>
>
>
>
>
>
>
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/