PureBytes Links
Trading Reference Links
|
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 );
----- Original Message -----
From: "Charles J. Dudek" <trader@xxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, November 07, 2006 7:58 AM
Subject: [amibroker] Linear Trend with Automatic Start Point
>I would like to have a trend line drawn using the last buy/sell signal
> as the starting point. I have not been able to figure out how to do
> that and would like some suggestions. Here is what I tried, which has
> not gotten an error message, but it has not produced anything either.
> I know the rest of the code works to draw a line and the only thing
> I'm manipulating is the daysbackb variable. Can this work without a
> lot of complex coding?
> .
> .
> .
> 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 ) );
> .
> .
> .
>
> Thanks for any help.
>
> Chuck
>
>
>
>
> 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
>
>
>
>
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.11/542 - Release Date: 11/20/2006
|