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

Re: [RT] Clyde's Lineareg.ela



PureBytes Links

Trading Reference Links


This is one of several requests that I have 
had for modifications
of the linear regression 
routine.
 
The following is the code for the changes 
that I have made.
 
I would suggest that you read this 
information carefully as this
now can get to be a complicated tool to 
use.  However, it will
retain the same simplicity as the original 
if you let it.  See
the explanations on  junk2.gif  
.
 
You can now specify a start and an end date 
and the indicator will
calculate length and apply.
 
You can specify a beginning date and length 
or an ending date and
a length or neither and a 
length.
 
You have almost total control over the 
color and weights of the
mid and channel lines and the spacing to 
the channel lines.
 
I have not had a chance to run this in 
realtime yet but supposedly
it will update on a realtime basis.  
Who knows until we try it!!
 
The  .ela  file was generated 
by  TS4  and should run in TS4 and SC.
 
I hope you folks use this and post some 
results from it.
 
Clyde
 
 
 
 
 
<FONT face="Courier New" 
size=2>{*******************************************************************Description 
: This Indicator plots Linear Regression LineProvided By : Omega 
Research,Inc. (c) Copyright 1999 Modified By : Clyde Lee (c) 2000,include 
parallel 
lines.              
Add start date, start-end date 
definition.********************************************************************}inputs: 
  Length(60),      {This is set to difference 
in Start & End dates  
}                   
{if both are specified and is ignored 
then       } 
                   
{if set to zero and begin (but not end) date is  
}                   
{specified then length is from begin date to     
}                   
{last bar on 
chart                               
}                   
{NOTE:  If length is specified and begin/end 
date}                   
{and time are set to zero then trendline and the 
}                   
{channel lines if specified are calculated (and  
}                   
{in real time updated) from the last bar on the  
}                   
{chart backwards for length 
specified.           
}  BegDate(0),      {YYYMMDD-if specified 
fixes begin of compute     }   
BegTime(0),      {Set to zero to ignore 
time                      
}  EndDate(0),      {YYYMMDD-if specified 
fixes end of compute       }  
EndTime(0),      {Set to zero to ignore 
time                      
}  ColSizMd(6.1),   {x.y  x=color   y=line 
size (0-6)  for mid line  
}                   
{Black=1,      Blue=2,    
Cyan=3,     Green=4,   
}                   
{Magenta=5,    Red=6,     
Yellow=7,   White=8,   
}                   
{DarkBlue=9                                      
}                   
{DarkCyan=10, DarkGreen=11, DarkMagenta=12,      
}                   
{DarkRed=13,  DarkBrown=14, 
DarkGray=15,         
}                   
{LightGray=16                                    
}                   
{You can use:   red+.1  (red color, 
size=1)      
}                   
{if you do this DO NOT FORGET THE DECIMAL B4 LINE}  
ExtRight(True),  {Set false for no extension to mid/channel lines 
}  ChanWide(2),     {Multiplier of StdDev(c,Length) 
to set width     }  ColSizCh(2.1);   
{x.y  x=color   y=line size   for channel lines  
}
 
variables:   
LRV(0),          {Current linear 
regression value}  LRVAgo(0),       
{Linear regression value at begin of lines}  
TLLRV(0),TLLRV1(0),TLLRV2(0),  {TL ID's for mid and channel 
lines}  Flag(0),         
{basically the mode of operation}  ChanStdD(0),     
{Use initial standard deviation computation}  
UseLength(Iff(BegDate>0,0,Length)),  UseEndDate(EndDate),  
UseEndTime(EndTime),  UseBeginDate(BegDate),  
UseBeginTime(BegTime),  UseColor(ColSizMd-1),  
BeginBar(0);Variables:  MidColor(IntPortion(ColSizMd)),  
MidSize (IntPortion((ColSizMd-MidColor)*10)),  
ChnColor(IntPortion(ColSizCh)),  ChnSize 
(IntPortion((ColSizCh-ChnColor)*10));
 
If UseBeginDate>0 then begin  
{If begin date then find out and set BeginBar variable}  If 
Date>=BegDate and Time>=BegTime and BeginBar=0 then 
begin    BeginBar=CurrentBar;  End  Else if 
BeginBar>0 then begin    {Begin date detected so now look 
for end date and set when found}    If EndDate>0 or 
lastbaronchart then begin      if (Date>=EndDate 
and Time>=EndTime) or LastBarOnChart  then 
begin        
UseLength=CurrentBar-BeginBar;        
UseEndDate=Date;        
UseEndTime=Time;        
UseBeginDate=0;      
end      else if date<EndDate then 
UseLength=0;    End    Else If 
CurrentBar=BeginBar+Length then begin      {If 
length specified & no end date just set 
end}      
UseLength=Length;      
UseEndDate=Date;      
UseEndTime=Time;      
UseBeginDate=0;    End;  End;End;
 
{Once we have a good length then proceed to 
compute/draw lines}If UseLength>0  then begin    
if LastBarOnChart and EndDate=0 and Flag=0 then   
begin    Flag=1 ;  end ;  if 
Date=UseEndDate and (Time=UseEndTime or UseEndTime=0) and Flag=0 then 
begin    Flag=2 ;  end ;    if 
Flag=1 or Flag=2 then  begin
 
    LRV   
=LinearRegValue(Close,UseLength,0) ;    
Value1=LinearRegSlope(Close,UseLength) ;    
LRVAgo=LRV-(UseLength-1)*Value1;
 
    If Flag[1]=0 then 
begin      {If this is first time to draw then we 
must define the trendlines}      
TLLRV=TL_New(Date[UseLength-1],Time[UseLength-1],LRVAgo,Date,Time,LRV) 
;      TL_SetColor  (TLLRV,MidColor) 
;      TL_SetSize   
(TLLRV,MidSize);      TL_SetExtLeft(TLLRV,false) 
;      
Plot1(LRV,"ell");      
{SetPlotColor(1,UseColor);}      If ChanWide>0 
then begin        {Setup channel lines if 
specified}        
ChanStdD=StdDev(c,UseLength)*ChanWide;        
TLLRV1=TL_New(Date[UseLength-1],Time[UseLength-1],LRVAgo+ChanStdD,Date,Time,LRV+ChanStdD) 
;        
TLLRV2=TL_New(Date[UseLength-1],Time[UseLength-1],LRVAgo-ChanStdD,Date,Time,LRV-ChanStdD) 
;      End;    
End;        if Flag=1 then  
begin      {If not first time and we are moving 
lines then just update trendlines}      
TL_SetBegin(TLLRV,Date[UseLength-1],Time[UseLength-1],LRVAgo) 
;      TL_SetEnd  (TLLRV,Date,Time,LRV) 
;      
Plot1(LRV,"ell");      {Move start/end of channel 
lines if specified}      If ChanWide>0 then 
begin        
TL_SetBegin(TLLRV1,Date[UseLength-1],Time[UseLength-1],LRVAgo+ChanStdD) 
;        TL_SetEnd  
(TLLRV1,Date,Time,LRV+ChanStdD) ;        
TL_SetBegin(TLLRV2,Date[UseLength-1],Time[UseLength-1],LRVAgo-ChanStdD) 
;        TL_SetEnd  
(TLLRV2,Date,Time,LRV-ChanStdD) ;      
End;    end ;      if Flag=2 
then    Flag=3 ;
 
    {Set colors, extensions, 
width of line for median line}    TL_SetColor  
(TLLRV,MidColor) ;    TL_SetSize   
(TLLRV,MidSize);    TL_SetExtLeft(TLLRV,false) 
;    if ExtRight       
then  TL_SetExtRight(TLLRV,true)      
else  TL_SetExtRight(TLLRV,false) ;      If 
ChanWide>0 then begin      {Set colors, 
extensions, width of line for channel lines}      
TL_SetColor  (TLLRV1,ChnColor) ;      
TL_SetColor  (TLLRV2,ChnColor) ;      
TL_SetSize   (TLLRV1,ChnSize);      
TL_SetSize   (TLLRV2,ChnSize);      
TL_SetExtLeft(TLLRV1,false) ;      
TL_SetExtLeft(TLLRV2,false) ;      if ExtRight then 
begin        
TL_SetExtRight(TLLRV1,true);        
TL_SetExtRight(TLLRV2,true);      
end      else 
begin        TL_SetExtRight(TLLRV1,false) 
;        TL_SetExtRight(TLLRV2,false) 
;      end;    End;  
end ;
 
End;  {End of loop waiting for end 
date if begin date specified}
 
{*** Copyright (c) 1991-2000 TradeStation. All rights reserved. 
***}
 
 
 
 
 
- - - - - - - - - - - - - - - - - - - - -  - - - - - - -Clyde 
Lee   
Chairman/CEO          (Home of 
SwingMachine)SYTECH 
Corporation          email: <A 
href="mailto:clydelee@xxxxxxxxxxxx";>clydelee@xxxxxxxxxxxx  7910 
Westglen, Suite 105       
Office:    (713) 783-9540Houston,  TX  
77063               
Fax:    (713) 783-1092Details 
at:                      
www.theswingmachine.com- - - - 
- - - - - - - - - - - - - - - -  - - - - - - - -
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  ----- Original Message ----- 
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black">From: 
  <A title=patchc@xxxxxxxxxxxxxxxxxxxxx 
  href="mailto:patchc@xxxxxxxxxxxxxxxxxxxxx";>Darrell 
  To: <A title=realtraders@xxxxxxxxxxxxxxx 
  href="mailto:realtraders@xxxxxxxxxxxxxxx";>realtraders@xxxxxxxxxxxxxxx 
  
  Sent: Friday, July 06, 2001 01:36
  Subject: [RT] Clyde's Lineareg.ela
  
  This email was delivered to you by The 
  Free Internet,a Business Online Group company. <A 
  href="http://www.thefreeinternet.net";>http://www.thefreeinternet.net
  
  
  Clyde, many thanks for the lineareg.ela. I do not 
  have the programming ability,
  however is it possible to modify the ela so that 
  you can choose the start date 
  and then let the end date float <FONT 
  face=Arial size=2>as at present, rather than 
  specify the lookback 
  length for the linear reg. It would <FONT 
  face=Arial size=2>then have the <FONT face=Arial 
  size=2>same characteristics as the 
  
  AGet linear reg.
   
  Thanks in 
advance.



To unsubscribe from this group, send an email to:
realtraders-unsubscribe@xxxxxxxxxxxxxxx





Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Attachment: Description: "linreg2.ela"

Attachment: Description: "junk2.gif"