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

Re: Regression channel indicator



PureBytes Links

Trading Reference Links

I posted this to MB’s code-list some time ago. I usually do not cross
post on the two lists .

Other indicators of volatility, such as SD, can be substituted into the
input K. An alert is included which can be omitted. Copy into the
clipboard and then paste into the powereditor. I assume you are using
TS2K which has the LinearRegValue. If you are using TS 4 then you need
to import this function (from TS2K).

                        

Input:Len(20),offset(1),K(AvgTrueRange(10)),Color(2),ExtRight(false);
Variables: LRV(0), LRV1(0),LRV2(0),LRVAgo(0),LRVAgo1(0),LRVAgo2(0),
         TL(0), TL1(0), TL2(0), Flag(0),flag1(0),flag2(0),
        z(0), x(0), y(0),g(0),j(0);

Z= C;
   g=LinearRegValue(z, Len, 0);
   j= LinearRegValue(z, Len, Len-1);
   x=LinearRegSlope(z,LEN);

       LRV =offset*k+ g;               LRVAgo =offset*k+j;

   If LastBarOnChart  AND Flag = 0 Then Begin
     TL = TL_New(D[Len-1], T[Len-1], LRVAgo, D, T, LRV);
          Flag = 1;      
   End;    
   If Flag = 1  Then Begin
      TL_SetColor(TL, Color);
      TL_SetExtRight(TL, ExtRight);
      TL_SetBegin(TL, Date[Len-1], Time[Len-1], LRVAgo);
      TL_SetEnd(TL, D, T, LRV);
   End;    
If CheckAlert  then
     if x<0 and z crosses over LRV then 
          alert=true;    
 
{...........................................}   
                LRV1 =0*k+ g;           LRVAgo1 =0*k+ j;

  If LastBarOnChart  AND Flag1 = 0 Then Begin
      TL1 = TL_New(D[Len-1], T[Len-1], LRVAgo1, D, T, LRV1);
            Flag1 = 1;
  End;    
  If Flag1 =1   Then Begin
     TL_SetColor(TL1, Color);
     TL_SetExtRight(TL1, ExtRight);
     TL_SetBegin(TL1, D[Len-1], T[Len-1], LRVAgo1);
     TL_SetEnd(TL1, Date, Time, LRV1);
  End;

{...................................................}
       LRV2 =-1*offset*k+g;       LRVAgo2 =-1*offset*k+j;

  If LastBarOnChart AND Flag2 = 0 Then Begin
     TL2 = TL_New(D[Len-1], T[Len-1], LRVAgo2, D, T, LRV2);
          Flag2 = 1;             
  End;    
  If Flag2 = 1 Then Begin
      TL_SetColor(TL2, Color);
      TL_SetExtRight(TL2, ExtRight);
      TL_SetBegin(TL2, D[Len-1], T[Len-1], LRVAgo2);
      TL_SetEnd(TL2, D, T, LRV2);
  End;
If CheckAlert  then
     if x>0 and z crosses under LRV2 then 
           alert=true; 

if 2=1 then plot1(flag2,"");



Wayne Mathews