I can't seem to find one under PublicFunctions, can someone shed some light?
Thanks.
Exponential Moving Average function, is there one?
Re: Exponential Moving Average function, is there one?
Found it, PowerLanguage.Function.XAverage, but I have a few questions
1) Is it always a 3 step process to simply make a function call?
a) Create function object in Create()
b) Set function params in StartCalc()
c) Use function return values in CalcBar()?
2) If I need to calculate EMA of a few different series, I will need to create that many instances of the XAverage function, and repeat each of above 3 steps?
3) Is there any plan to simplify this model, and make it look like a straightforward function call?
e.g. A = XAverage(xxx, yyy) ?
Thank you very much!
1) Is it always a 3 step process to simply make a function call?
a) Create function object in Create()
b) Set function params in StartCalc()
c) Use function return values in CalcBar()?
2) If I need to calculate EMA of a few different series, I will need to create that many instances of the XAverage function, and repeat each of above 3 steps?
3) Is there any plan to simplify this model, and make it look like a straightforward function call?
e.g. A = XAverage(xxx, yyy) ?
Thank you very much!
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Exponential Moving Average function, is there one?
Hello ivanyu,1) Is it always a 3 step process to simply make a function call?
a) Create function object in Create()
b) Set function params in StartCalc()
c) Use function return values in CalcBar()?
That is correct.
That is correct.2) If I need to calculate EMA of a few different series, I will need to create that many instances of the XAverage function, and repeat each of above 3 steps?
There is no way to do that.3) Is there any plan to simplify this model, and make it look like a straightforward function call? e.g. A = XAverage(xxx, yyy) ?
-
- Posts: 6
- Joined: 26 Aug 2013
- Has thanked: 1 time
Re: Exponential Moving Average function, is there one?
I find something interesting in the code of XAverage . The class variables Price and Length are start with capital letter.
In other functions they are in small letter.
Is there any particular reason to do it like that?
Will it case any problem when you need to include XAverage with other functions?
namespace PowerLanguage.Function
{
public sealed class XAverage : FunctionSeries<double>
{
public XAverage(CStudyControl _master) : base(_master) {}
public XAverage(CStudyControl _master, int _ds) : base(_master, _ds) {}
public ISeries<double> Price { private get; set; }
public int Length { private get; set; }
protected override double CalcBar(){
if (1 == Bars.CurrentBar)
return Price[0];
double prev = this[1];
return prev + 2.0 / (Length + 1) * (Price[0] - prev);
}
}
}
In other functions they are in small letter.
Is there any particular reason to do it like that?
Will it case any problem when you need to include XAverage with other functions?
namespace PowerLanguage.Function
{
public sealed class XAverage : FunctionSeries<double>
{
public XAverage(CStudyControl _master) : base(_master) {}
public XAverage(CStudyControl _master, int _ds) : base(_master, _ds) {}
public ISeries<double> Price { private get; set; }
public int Length { private get; set; }
protected override double CalcBar(){
if (1 == Bars.CurrentBar)
return Price[0];
double prev = this[1];
return prev + 2.0 / (Length + 1) * (Price[0] - prev);
}
}
}
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Exponential Moving Average function, is there one?
webspiderc, C# is a case sensitive programming language. There should be no problem if you are using the proper register in your code.