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

Re: [amibroker] Re: An indicator tricky to code !!! (for AFL gurus)



PureBytes Links

Trading Reference Links


Hi JJ,

You are an AFL guru !!! Your code works like a charm ;-) .

Thanks again ;-)
Regards,

Khamsina


JJ a écrit :
Khamsina11 wrote:
  
...I just can't translate it into AFL :-( . 
Unfortunately, it far more difficult for me (loop, array).
    

here it is (i think).  hopefully you have something to compare with. 
let me know if it is wrong and i'll have another go at it. use ctrl-R
to call up the PARAM feature.  adjust between 1 and 100.

brian and joe, this is not a linear regression and there is no need to
have it explained. it's just code.

\jeff

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

Len=Param("Len",10,1,100,1);
k=1.253314;

Mean = MA(Avg, Len);
SumSqr=0;

for (i=Len-1;i<BarCount;i++)
{
for (j =0 ;j<Len;j++)
{
  X[j] = C[i-j] - Mean[i];

	if(j==0) MaxY=MinY=Y[j]=X[j];
		else 
			{
			Y[j] = Y[j-1] + X[j];
			if(Y[j] > MaxY) MaxY = Y[j];
			  if (Y[j] < MinY) MinY = Y[j];
			}
  SumSqr[i] = SumSqr[i] + X[j]^2;
}
Rng[i]= MaxY - MinY;
}

scale=sqrt(SumSqr/Len);
Estmtr = log(Rng/(k * Scale)) / log(Len);
Plot(Estmtr,"Estmtr",colorBlack,styleLine);


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

original code:

  
Inputs: Len(Numeric);
Vars: Mean(0), j(0), k(1.253314), SumSqr(0), Scale(0), MaxY(0),  
MinY(0), Rng(0);
Arrays: X[100](0), Y[100](0);

Mean = Average((h+c+l)/3, Len);
SumSqr = 0;
for j = 0 to Len - 1 begin
  X[j] = C[j] - Mean;
  SumSqr = SumSqr + X[j] * X[j];
end;
Scale = SquareRoot(SumSqr / Len);
Y[0] = X[0];
MaxY = X[0];
MinY = X[0];
for j = 1 to Len - 1 begin
  Y[j] = Y[j - 1] + X[j];
  if Y[j] > MaxY then MaxY = Y[j];
  if Y[j] < MinY then MinY = Y[j];
end;
Rng = MaxY - MinY;
Estmtr = Log(Rng/(k * Scale)) / Log(Len);
    




------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

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

<*> 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/
 



  


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links