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

RE: [amibroker] LINEAR REGRESSION CHANNEL



PureBytes Links

Trading Reference Links

In addition to the tool I use this formula to have a Linerar Regression channel set up all the time for my charts

The following works for me,  maybe this might help

 

 

_SECTION_BEGIN("LinearRegression");

 

 

P = ParamField("Price field",-1);

Daysback = Param("Period for Liner Regression Line",21,1,240,1);

shift = Param("Look back period",0,0,240,1);

 

 

//  =============================== Math Formula =============================================================

 

x = Cum(1);

lastx = LastValue( x ) - shift;

aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );

bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );

y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );

 

 

// ==================Plot the Linear Regression Line ==========================================================

 

 

LRColor = ParamColor("LR Color", colorCycle );

LRStyle = ParamStyle("LR Style");

 

LRLine =  IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );

Plot( LRLine , "LinReg", LRCOLOR, LRSTYLE|styleNoRescale  ); //  styleDots );

 

// ==========================  Plot 1st SD Channel ===============================================================

 

SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);

SD = SDP/2;

 

width = LastValue( Ref(SD*StDev(p, Daysback),-shift) );   // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET 

SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;

SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;

 

SDColor = ParamColor("SD Color", colorCycle );

SDStyle = ParamStyle("SD Style");

 

Plot( SDU , "Upper Lin Reg", SDColor,SDStyle|styleNoRescale  );

Plot( SDL , "Lower Lin Reg", SDColor,SDStyle|styleNoRescale  );

 

//  ==========================  Plot 2d SD Channel ===============================================================

 

SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);

SD2 = SDP2/2;

 

width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) );   // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET 

SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;

SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;

 

SDColor2 = ParamColor("2 SD Color", colorCycle );

SDStyle2 = ParamStyle("2 SD Style");

 

Plot( SDU2 , "Upper Lin Reg", SDColor2,SDStyle2|styleNoRescale  );

Plot( SDL2 , "Lower Lin Reg", SDColor2,SDStyle2|styleNoRescale  );

 

// ============================ End Indicator Code ==============================================================

 

_SECTION_END();

 

 

 

 

Mark

 

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Joe Landry
Sent: Monday, September 12, 2005 10:30 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] LINEAR REGRESSION CHANNEL

 

Joe

There's a tool in your tool bar that plots linear regression line...the length of

your choice and channel of your choice Raff, Std Dev.or Std Error.  

My tool bar is on the right hand side of the chart display and by hovering your cursor over it

you'll see what it's called - "regression channel"

 

JOE

----- Original Message -----

From: grady129

Sent: Sunday, September 11, 2005 10:54 AM

Subject: [amibroker] LINEAR REGRESSION CHANNEL

 

Is it possible to plot LINEAR REGRESSION CHANNEL in Amibroker?
If it is, how do I do that.

Thank you in advance for your help.

Joe







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 Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS