Joe, that's pretty cool, but it doesn't really help me because I want
the starting point to be defined automatically so I can backtest it
without defining it by having to look at the chart.  Is it possible to
use a barssince value to define the period for the regression as in my
example?

> > Daysbackb = LastValue(LowestSinceBars( Buy, C)); 
> > shift = Param("Look back period",0,0,50000,1); 
> > xb = Cum(1);
> > lastxb = LastValue( xb ) - shift; 
> > ab = LastValue( Ref(LinRegIntercept( p, Daysbackb), -shift) ); 
> > bb = LastValue( Ref(LinRegSlope( p, Daysbackb ), -shift) ); 
> > yb = Ab + bb * ( xb - (Lastxb - DaysBackb +1 ) );

Chuck

--- In [email protected], "Joe Landry" <[EMAIL PROTECTED]> wrote:
>
> Charles -  I didn't look at your code but here's food for thought. 
This clip
> from another script draws a trendline starting from the cursor going
back in time. 
> HTH, Joe 
> _SECTION_BEGIN("slope study");
> 
> Plot(C,"Close",1,64); 
> 
> _TRACE("DBGVIEWCLEAR"); 
> 
> // LINEAR REGRESSION LINE
> 
> Daysback = Param("Lookback",20,2,100,1); 
> 
> x = Cum(1); 
> 
> lastx = SelectedValue( x );
> 
> // Lastx = LastValue(x); 
> 
> // Set last bar at selected value
> 
> // Plot from that point backwards for NN bars say 10
> 
> i = LinRegIntercept(Close,Daysback); 
> 
> aa = LastValue(ValueWhen(x ==Lastx,i)); 
> 
> s = LinRegSlope(Close,Daysback); 
> 
> bb = LastValue(ValueWhen(x==Lastx,s)); // Slope of the regressed line
> 
> _TRACE("Intcpt= "+aa +" Slope= "+bb); 
> 
> y = Aa + bb * ( x - (Lastx - DaysBack) );
> 
> _TRACE("lastx= "+ Lastx + " LX - 20= "+ (Lastx-20)); 
> 
> Plot( IIf( x >= ( Lastx-daysback) AND x <= Lastx, y, -1e10 ),
"LinReg", colorRed,8 );




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> 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/
 

Reply via email to