|
|
|
|
|||||||
| Trading Indicators Post your custom trading indicators. If you download, remember to click INSTALL. |
![]() |
| Bookmarks | |||||||
del.icio.us
|
StumbleUpon
|
Google
|
Digg
|
Facebook
|
Furl
|
Reddit
|
Netscape
|
|
|
LinkBack | Release Tools | Display Modes | Language |
|
Linear Regression Channel
Developer Last Online: Apr 2008
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. |
||||||||||||
|
Show Your Support
|
||||||||||||
|
|
||||||||||||
|
By
thrunner
on
02-06-2008, 12:52 AM
|
|
Re: Linear Regression Channel
Thanks wsam. The LRC url above eventually links to Pat Barham's webinar on grains.
You can skip to the first hour (about 55 to 60th minute) to see the Linear Regression Channel analysis on grains where Pat uses 50 and 100 period LRCs. |
![]() |
| Currently Active Users Viewing This Release: 1 (0 members and 1 guests) | |
| Release Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Release | Release Starter | Category | Comments | Last Post |
| 'Linear Regression Line' indicator in Tradestation | Dogpile | Coding Forum | 1 | 11-30-2007 01:01 PM |