Exponential Moving Average function, is there one?

Questions about MultiCharts .NET and user contributed studies.
ivanyu
Posts: 31
Joined: 24 Jul 2013
Has thanked: 3 times
Been thanked: 1 time

Exponential Moving Average function, is there one?

Postby ivanyu » 01 Sep 2013

I can't seem to find one under PublicFunctions, can someone shed some light?

Thanks.

ivanyu
Posts: 31
Joined: 24 Jul 2013
Has thanked: 3 times
Been thanked: 1 time

Re: Exponential Moving Average function, is there one?

Postby ivanyu » 01 Sep 2013

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!

User avatar
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?

Postby Henry MultiСharts » 05 Sep 2013

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()?
Hello ivanyu,

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?
That is correct.
3) Is there any plan to simplify this model, and make it look like a straightforward function call? e.g. A = XAverage(xxx, yyy) ?
There is no way to do that.

webspiderc
Posts: 6
Joined: 26 Aug 2013
Has thanked: 1 time

Re: Exponential Moving Average function, is there one?

Postby webspiderc » 05 Sep 2013

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);
}
}
}

User avatar
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?

Postby Henry MultiСharts » 10 Sep 2013

webspiderc, C# is a case sensitive programming language. There should be no problem if you are using the proper register in your code.


Return to “MultiCharts .NET”