Januson
05-17-2007, 01:07 PM
Hello...
To get myself at the right track from the beginning, I've a couple of questions.
I'm trying to translate an .ELD file from Tradestation, this .ELD uses a function called XAverageOrig, take a look here:
inputs:
Price( numericseries ),
Length( numericsimple ) ; { this input assumed to be a constant >= 1 }
variables:
SmoothingFactor( 1 / Length ) ;
if CurrentBar = 1 then
XAverageOrig = Price
else
XAverageOrig = XAverageOrig[1] + SmoothingFactor * ( Price - XAverageOrig[1] ) ;
I'm a little confused, should I code it as an indicator ie. like SMA or should it be a custom method? I did try to program it as a method:
public double XAverageOrig(IDataSeries price, int length)
{
double smoothingFactor = 1/length;
if (CurrentBar == 1)
return price[0];
else
return XAverageOrig(price, length) + smoothingFactor * (price[0] - XAverageOrig(price, length));
}
But as I feared it behaved like a recursion and killed my CPU :p
Any help?
Kind regards
Januson
To get myself at the right track from the beginning, I've a couple of questions.
I'm trying to translate an .ELD file from Tradestation, this .ELD uses a function called XAverageOrig, take a look here:
inputs:
Price( numericseries ),
Length( numericsimple ) ; { this input assumed to be a constant >= 1 }
variables:
SmoothingFactor( 1 / Length ) ;
if CurrentBar = 1 then
XAverageOrig = Price
else
XAverageOrig = XAverageOrig[1] + SmoothingFactor * ( Price - XAverageOrig[1] ) ;
I'm a little confused, should I code it as an indicator ie. like SMA or should it be a custom method? I did try to program it as a method:
public double XAverageOrig(IDataSeries price, int length)
{
double smoothingFactor = 1/length;
if (CurrentBar == 1)
return price[0];
else
return XAverageOrig(price, length) + smoothingFactor * (price[0] - XAverageOrig(price, length));
}
But as I feared it behaved like a recursion and killed my CPU :p
Any help?
Kind regards
Januson