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

Re: The Mysteries of Easy Language



PureBytes Links

Trading Reference Links

Vista-Research wrote:

> In brief, without reproducing your test, I would comment that the XAverage
> IS a series function.  That I can not imagine it working correctly as a
> simple function...

Here are two versions an EMA, type series:

Inputs: Price(numericseries), Len(numeric);
Vars: Factor(0), Return(0);
Arrays: Store[1](Price) ;

Factor = 2/ (Len+1);

If currentbar <=1 then Return = Price
Else Return = Factor * Price + (1 - Factor) * Store[0] ;
Store[0] = Return ;

XAve = Return ;


This is Bob Fulks version, I believe. It should give the same results.

Inputs: Price(numericseries), Len(numeric) ;
Vars: Factor(0), XLast(0);

If Len + 1 <> 0 then begin
	If CurrentBar <= 1 then begin
		Factor = 2 / (Len + 1);
		XAve = Price;
		XLast = Price;
	End
	Else begin
		Value1 = Factor * Price + (1 - Factor) * XLast;
		XAve = Value1;
		XLast = Value1;
	End;
End;


I've sometimes had luck correcting initialization problems with
functions & indicators by initializing a Var with the correct value. For
example, in the first function I might use:

Vars: Vars: Factor(0), Return(Price);

Or even:

Vars: Factor(0), Return(Average(Price,Len));

Haven't tested either with that function, so I'm not sure if it would
make any difference.


Cheers,

Cab Vinton
cvinton@xxxxxxxxxxx