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

Re: Bamboozled by "Easy" Language



PureBytes Links

Trading Reference Links

Dans un courrier daté du 30/10/98 22:16:54 Heure d10iver Pari54 Madrid,
flag@xxxxxxxxxxxx a écrit :

>  know that there are many list members smarter than I when it comes to
>  programming.  So, I hope some one of you could take a moment to explain to
>  me why the following code does verify in power editor:
>  
>  ( 1) plot1(Average((C of Data1/C of Data2),20),"RS");
>  
>  
>  Yet, the code below does not verify in power editor:
>  
>  (2) plot1(XAverage((C of Data1/C of Data2),20),"RS");
>  
>  
>  nor does this:
>  
>  (3) RS=XAverage((C of Data1/C of Data2),20);
>  (4) plot1(RS,"RS");
>  
>  
>  Statement (1) works fine. Statement (2) produces an error message along the
>  lines of,  "unresolvable data number". Statements (3) and (4) produce an
>  error message along the lines of,  "variables and arrays not allowed here".
>  
>  Clint

Statement (1) works because it' not a recursive calculation.

Statement (2-3-4)  do not, because of some internal security check buried into
EL.
If you examin the Xaverage Code, it makes reference to XAverage[1], until the
first bar where Xaverage must be a raw price series (what is not c data1 / c
data2).

inputs : Price(NumericSeries),Length(NumericSimple);
vars   : Factor(0);

if Length + 1 <> 0 
then begin
	if CurrentBar <= 1 
	then begin
		Factor = 2 / (Length + 1);
		XAverage = Price;  <=======must be a defined serie when using recursive
calculation.
	end
	else  
		XAverage = Factor * Price + (1 - Factor) * XAverage[1];
end;

If you want to  bypass this, you have to use a diferent version of
Xaverage,that do not refer to Xaverage[1]

if Length + 1 <> 0 
then begin
	if CurrentBar <= 1 
	then begin
		Factor = 2 / (Length + 1);
		XXAverage = Price;
	end
	else  
		XXAverage = Factor * Price + (1 - Factor) * XXAverage; <===remember that
XXaverage is in fact XXaverage[1] until the end of the line
end;

As a function cannot refer to itslf, you will need to write:


inputs : Price(NumericSeries),Length(NumericSimple);
vars   : Factor(0),xavg0(0);

if Length + 1 <> 0 
then begin
	if CurrentBar <= 1 
	then begin
		XAvg0 = Price;
	end
	else  
		Factor = 2 / (Length + 1);
		XAvg0= Factor * Price + (1 - Factor) * XAvg0;
end;

xavg=xavg0;

The next version of EL will be less rstrictive that this one.

Sincerely,

Pierre Orphelin.