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

[amibroker] Lin Regression Hist



PureBytes Links

Trading Reference Links

Hi all!
I'm trying to convert EasyLang code into AFL. But i think i've made
many bugs in the code. This indicator was made by Clyde Lee and posted
on Swing Group. There is 4 colors in original version but i have only 2.
Can anybody help???

Easy code:
{*******************************************************************
Indicator:    Lin Regression Hist
Description : This Indicator plots difference in Linear Regression Lines
Provided By : Omega Research,Inc. (c) Copyright 1999
Modified By : Clyde Lee (c) 2007,CREATE A HISTOGRAM DISPLAY.
                     Of the Raff channel lines and the closing price.
********************************************************************}
inputs:
  Length( 34),     {Length for LR calculation of Raff Channels.     }
                         {The difference in the current closing price
and  }
                         {the channel lines is computed and plotted. 
      }
  LongMult(2),    {Multiplier of Length to get long length.             }
  Smooth(3),       {Length for smoothing filter.                     
       }
  ChanWide(2);   {Multiplier of StdDev(c,Length) to set width.     }
                         {Negative is multiplier (%) of closing price.
       }
 

variables:
 UseLength(Iff(Length<9,9,Length)),
 UseLength1(IntPortion(UseLength*LongMult)),
 ChanStdD(0),
 WideChan(Iff(ChanWide<=0,1,ChanWide)),
  LRV1(0), {Current linear regression valueS}
  LRV(0); {Current linear regression valueS}
 
If ChanWide>0 then ChanStdD=StdDev(MedianPrice,UseLength)*WideChan
         else ChanStdD=MedianPrice/100*WideChan;
 
If LongMult>0 then begin
 LRV1   = LinearRegValue(MedianPrice,UseLength1,0) ;
 
 Value10=(c-(LRV1+ChanStdD))-((LRV1-ChanStdD)-c);
 If Smooth>0 then Value11=XAverage(Value10,Smooth)
             else Value11=Value10;
 If Value11>0 then Plot3(Value11,"el1+")
              else Plot4(Value11,"el1-");
End;
 

LRV   =LinearRegValue(MedianPrice,UseLength,0) ;
 
Value0=(c-(LRV+ChanStdD))-((LRV-ChanStdD)-c);
If Smooth>0 then Value1=XAverage(Value0,Smooth)
           else Value1=Value0;
 
If Value1>0 then Plot1(Value1,"el+")
            else Plot2(Value1,"el-");
 
{   
Value21=Value11-Value1;
If Value21>0 then Plot2(Value21,"el+")
             else Plot3(Value21,"el-");
} 


And here is my AFL:
Length = Param("Length", 34, 0, 500, 1);
LongMult = Param("LongMult", 2, 0, 10, 0.5);
Smooth = Param("Smooth", 3, 0, 10, 1);
ChanWide = Param("ChanWide", 2, 0, 10, 1);

UseLength = IIf(Length<9,9,Length);
WideChan = IIf(ChanWide<=0,1,ChanWide);
UseLength1 = int(UseLength*LongMult);
MedianPrice = (H+L)/2;

if ( ChanWide > 0 )
ChanStdD = StDev(MedianPrice,UseLength)*WideChan;
else
ChanStdD = MedianPrice/100*WideChan;


if (LongMult > 0)
{
 LRV1   = LinearReg(MedianPrice,UseLength1);
 Value10=(C-(LRV1+ChanStdD))-((LRV1-ChanStdD)-C);
 
if (Smooth>0)
Value11= EMA(Value10,Smooth);
else
Value11=Value10;


for( i = 1; i < BarCount; i++ )
{
 if (Value11[i]>0)
{Plot( Value11,"el1+", colorRed, styleHistogram);}
else
{Plot( Value11,"el1-", colorYellow, styleHistogram); }
}
}


LRV = LinearReg(MedianPrice,UseLength);
Value0=(C-(LRV+ChanStdD))-((LRV-ChanStdD)-C);

if (Smooth>0)
Value1=EMA(Value0,Smooth);
else
Value1=Value0;
 
for( i = 1; i < BarCount; i++ )
{
  if (Value1[i]>0)
    {
     Plot( Value1,"el+", colorBlue, styleHistogram);
   }
   else
   {
      Plot( Value1,"el-", colorLightBlue, styleHistogram);
   }
}  

Thanks!!!



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/