Welcome to the Traders Laboratory Forums.
Trading Indicators Post your custom trading indicators. If you download, remember to click INSTALL.

Reply
Linear Regression Channel Details »»
Linear Regression Channel
Platform: , by wsam29 wsam29 is offline
Developer Last Online: Mar 2008 Show Printable Version Email this Page

Platform: Unknown Rating:
Released: 02-05-2008 Last Update: Never Installs: 0
 
No support by the author.

I have no clue how to upload the indicator so I'll just post the coding.

[LegacyColorValue = true];
{Updated by DJ Reda on Sat 4/16/05
Added option to use either Standard Deviation or Standard Error of Estimate to plotchannel bands}
{ // Note: Setting a begin date that is earlier than the amount of length for the regression
will produce an extend to the left model that is date and time restricted
The End Date must not be in the future // }

inputs:
STD1_SEE2(2),
Length ( 50), { // Length of Linear Regression // }
Size(1),//Trend Line Thickness
BeginDate ( 0), { // Choose Zero to use full length // }
BeginTime ( 0), { // Choose Zero to use full time // }
EndDate ( 0), { // Choose Zero for Current Day // }
EndTime ( 0), { // Choose Zero for Current Time // }
NumDevsUp ( 2), { // Standard deviations for upper // }
NumDevsDn ( -2), { // Standard deviations for lower // }
LRColor ( Green), { // Color for Linear Regression Line // }
STDDevColor( Magenta), { // Color for Upper Boundary // }
SEEColor(Magenta) , { // Color for Lower Boundary // }
ExtRight ( false), { // Set to true to extend to right // }
ExtLeft ( false); { // Set to true to extend to left // }

variables:
FirstDate ( 0 ),
FirstTime ( 0 ),
UpperBand ( 0 ),
LowerBand ( 0 ),
UpperBand_1 ( 0 ),
LowerBand_1 ( 0 ),
LRV ( 0 ),
LRV_1 ( 0 ),
TL_LRV ( 0 ),
TL_UB ( 0 ),
TL_LB ( 0 ),
Flag ( 0 ),
SDev ( 0 );


if BeginDate = 0 then
FirstDate = date[ Length - 1 ]
else
FirstDate = BeginDate;

if BeginTime = 0 then
FirstTime = time[ Length - 1 ]
else
FirstTime = BeginTime;


{ ///////////////////////////////////////////////////////////////////// }

if Flag = 0 then
begin
if ( EndDate = CurrentDate or EndDate = 0 ) and LastBarOnChart then
begin
LRV = LinearRegValue( Close, Length, 0 );
LRV_1 = LinearRegValue( Close, Length, Length - 1 );
{++++++++New Code to Choose between plotting Std Dev or Std Error++++++}
If STD1_SEE2 = 1 then
SDev = StandardDev( Close, Length, 1 );
If STD1_SEE2 = 2 then begin //use Standard Error of Estimate
Value1 = StdError(Close, Length);
SDEV = Value1;
end;
{++++++++End New Code++++++}

UpperBand = LRV + NumDevsUp * SDev;
LowerBand = LRV + NumDevsDn * SDev;
UpperBand_1 = LRV_1 + NumDevsUp * SDev;
LowerBand_1 = LRV_1 + NumDevsDn * SDev;

TL_LRV = TL_New( FirstDate, FirstTime, LRV_1, date, time, LRV );
TL_UB = TL_New( FirstDate, FirstTime, UpperBand_1, date, time, UpperBand );
TL_LB = TL_New( FirstDate, FirstTime, LowerBand_1, date, time, LowerBand );

Flag = 1 ;
end
else if date = EndDate and ( time = EndTime or EndTime = 0 ) then
begin
LRV = LinearRegValue( Close, Length, 0 );
LRV_1 = LinearRegValue( Close, Length, Length - 1 );

{++++++++New Code to Choose between plotting Std Dev or Std Error++++++}
If STD1_SEE2 = 1 then
SDev = StandardDev( Close, Length, 1 );
If STD1_SEE2 = 2 then begin //use Standard Error of Estimate
Value1 = StdError(Close, Length);
SDEV = Value1;
end;
{++++++++End New Code++++++}

UpperBand = LRV + NumDevsUp * SDev;
LowerBand = LRV + NumDevsDn * SDev;
UpperBand_1 = LRV_1 + NumDevsUp * SDev;
LowerBand_1 = LRV_1 + NumDevsDn * SDev;

TL_LRV = TL_New( FirstDate, FirstTime, LRV_1, date, time, LRV );
TL_UB = TL_New( FirstDate, FirstTime, UpperBand_1, date, time, UpperBand );
TL_LB = TL_New( FirstDate, FirstTime, LowerBand_1, date, time, LowerBand );

Flag = 2;
end;

if Flag = 1 or Flag = 2 then
begin
TL_SetColor( TL_LRV, LRColor );
If STD1_SEE2 = 1 then begin
TL_SetColor( TL_UB, STDDevColor );
TL_SetColor( TL_LB, STDDevColor );
end;
If STD1_SEE2 = 2 then begin
TL_SetColor( TL_UB, SEEColor );
TL_SetColor( TL_LB, SEEColor );
end;

TL_SetSize(TL_LRV, size);
TL_SetSize(TL_UB, size);
TL_SetSize(TL_LB, size);

TL_SetExtLeft( TL_LRV, ExtLeft );
TL_SetExtLeft( TL_UB, ExtLeft );
TL_SetExtLeft( TL_LB, ExtLeft );


TL_SetExtRight( TL_LRV, ExtRight );
TL_SetExtRight( TL_UB, ExtRight );
TL_SetExtRight( TL_LB, ExtRight );
end;

end
else
if Flag = 1 then
begin
LRV = LinearRegValue( Close, Length, 0 );
LRV_1 = LinearRegValue( Close, Length, Length - 1 );

{++++++++New Code to Choose between plotting Std Dev or Std Error++++++}
If STD1_SEE2 = 1 then
SDev = StandardDev( Close, Length, 1 );
If STD1_SEE2 = 2 then begin //use Standard Error of Estimate
Value1 = StdError(Close, Length);
SDEV = Value1;
end;
{++++++++End New Code++++++}

UpperBand = LRV + NumDevsUp * SDev;
LowerBand = LRV + NumDevsDn * SDev;
UpperBand_1 = LRV_1 + NumDevsUp * SDev;
LowerBand_1 = LRV_1 + NumDevsDn * SDev;

TL_SetBegin( TL_LRV, FirstDate, FirstTime, LRV_1 );
TL_SetBegin( TL_UB, FirstDate, FirstTime, UpperBand_1 );
TL_SetBegin( TL_LB, FirstDate, FirstTime, LowerBand_1 );

TL_SetEnd( TL_LRV, date, time, LRV );
TL_SetEnd( TL_UB, date, time, UpperBand );
TL_SetEnd( TL_LB, date, time, LowerBand );
end;

{ // Code modified from tradestation indicator of LinearRegLine
by
Greg Ballard, 04/09/2003 // }


This indicator was sent to me from Pat B. from TTM

LRC

I'd attach some screen shots of how I use the LRC, but I have no clue what I'm doing.

Screenshots

Linear Regression Channel-lrc_01.jpg   Linear Regression Channel-lrc_02.jpg  

Show Your Support

  • If you like to thanks you by the author -> Click Thanks to the Author
  • This modification may not be copied, reproduced or published elsewhere without the author's permission.

Similar Indicator
Mod Developer Type Replies Last Post
XCAP IPolyFit Tams Trading Indicators 3 11:14 AM 10-31-2009
XCAP IPolyFitPredict Tams Trading Indicators 3 06:12 AM 11-07-2009
XCAP_iPolyCycle Tams Trading Indicators 12 09:13 AM 03-04-2010
The Following 6 Users Say Thank You to wsam29 For This Useful Post:
aaa (05-23-2009), nomad4x (08-28-2008), Ranger (03-28-2010), Stat (03-12-2011), Tams (04-09-2009)

Comments
Old 08-12-2008, 10:49 AM   #10

daedalus's Avatar

Join Date: Jul 2007
Location: Omaha, NE
Posts: 627
Ignore this user

Thanks: 431
Thanked 551 Times in 228 Posts

Re: Linear Regression Channel

Would there anyway to modify this to allow it to be backtested? Just was curious!
daedalus is offline  
Reply With Quote
Old 05-22-2009, 09:14 PM   #11

Join Date: Jan 2007
Location: Toronto
Posts: 51
Ignore this user

Thanks: 2
Thanked 3 Times in 3 Posts

Re: Linear Regression Channel

Hi Guys,

I am not very good at all with paisting indicators in multicharts, can someone please tell me how to copy and past that code into multicharts or maybe post the indicator.
Many thanks,
email
email is offline  
Reply With Quote
Old 05-22-2009, 11:47 PM   #12

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,774
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Linear Regression Channel

Quote:
Originally Posted by email »
Hi Guys,
I am not very good at all with paisting indicators in multicharts, can someone please tell me how to copy and past that code into multicharts or maybe post the indicator.
Many thanks,
email

Open PowerEditor,

select File > New

enter indicator name,

paste in code.

click Compile
Tams is offline  
Reply With Quote
Old 05-23-2009, 06:52 AM   #13

Join Date: Jan 2007
Location: Toronto
Posts: 51
Ignore this user

Thanks: 2
Thanked 3 Times in 3 Posts

Re: Linear Regression Channel

Quote:
Originally Posted by Tams »
Open PowerEditor,

select File > New

enter indicator name,

paste in code.

click Compile
Tams,

Done, and it works. Many thanks Sir.
email is offline  
Reply With Quote
Old 08-02-2010, 07:36 PM   #14

Join Date: Aug 2010
Posts: 2
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Smile Re: Linear Regression Channel

dear
I am not very good at all with paisting indicators in multicharts, could someone please just post the indicator.( EazyLanguageDocumenFile)

thank you very much
alkha is offline  
Reply With Quote
Old 08-07-2010, 04:57 AM   #15
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: Linear Regression Channel

************************* **

Here it is

aaa is offline  
Reply With Quote
The Following User Says Thank You to aaa For This Useful Post:
Stat (03-12-2011)
Old 08-07-2010, 10:40 AM   #16

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,774
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Linear Regression Channel

.......... .......... Lol
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 11-14-2010, 06:40 AM   #17

Join Date: Aug 2010
Posts: 2
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Re: Linear Regression Channel

dear traders
I am very bad at all with paisting indicators in multicharts, could someone please just post the indicator.( EazyLanguageDocumen File)

thank you very much
alkha is offline  
Reply With Quote

Reply

Tags
regression

Thread Tools
Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Linear Regression Line' indicator in Tradestation Dogpile Coding Forum 1 11-30-2007 01:01 PM

All times are GMT -4. The time now is 04:43 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.