Is this using Function.DirMovement correct?  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
User avatar
svopex
Posts: 74
Joined: 16 Oct 2013
Has thanked: 7 times
Been thanked: 5 times
Contact:

Is this using Function.DirMovement correct?

Postby svopex » 12 Nov 2015

I must call dmiMinus.Call() and dmiPlus.Call()?

Code: Select all

namespace PowerLanguage.Strategy
{
public class TEST : SignalObject
{
private Function.DirMovement dmiMinus;
private Function.DirMovement dmiPlus;

public Svopex_TomNesBossBT(object _ctx)
: base(_ctx)
{
}

protected override void Create()
{
dmiMinus = new Function.DirMovement(this);
dmiPlus = new Function.DirMovement(this);
}

protected override void StartCalc()
{
dmiMinus.PriceH = Bars.High;
dmiMinus.PriceL = Bars.Low;
dmiMinus.PriceC = Bars.Close;
dmiMinus.Length = 64;
dmiPlus.PriceH = Bars.High;
dmiPlus.PriceL = Bars.Low;
dmiPlus.PriceC = Bars.Close;
dmiPlus.Length = 128;
}

protected override void CalcBar()
{
dmiMinus.Call();
dmiPlus.Call();

bool FiltrLong = dmiPlus.DMIPlus[0] <= dmiMinus.DMIMinus[0];

...
...
...
}
}
}

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Is this using Function.DirMovement correct?  [SOLVED]

Postby JoshM » 13 Nov 2015

I must call dmiMinus.Call() and dmiPlus.Call()?
You need to use function.Call only when the body of the series function is not being called for calculation directly. For example:

Code: Select all

if(MyCondition)
SomeValue = myfunction[0];
else
myfunction.Call();
Otherwise if you do not use function.Call where you need it - MultiCharts will do that for you, but at the end of the script calculation on the current bar. Depending on the code it can affect the function calculation results.
Source.

So in this case it's not needed because you already have the following statement in your code:

Code: Select all

bool FiltrLong = dmiPlus.DMIPlus[0] <= dmiMinus.DMIMinus[0];


Return to “MultiCharts .NET”