syntax question  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 33 times

syntax question

Postby darob » 14 Nov 2016

Hi, will MC.NET recognize that I want the m_avg.Value calculated on the 2nd data series in the following or is there something else I need to add?

if (BarsOfData(2).Close[0] < m_avg.Value) {

Many thanks

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 33 times

Re: syntax question

Postby darob » 14 Nov 2016

Ok it's definitely wrong, I'm getting a null reference exception: object reference not set to an instance of an object. So any help getting m_avg.Value to reference the 2nd data series appreciated. Thanks a lot.

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

Re: syntax question

Postby JoshM » 15 Nov 2016

Can you post more information about what `m_avg.Value` is? I suppose it's a variable series (`VariableSeries<T>`) given its `Value` property, but a variable series doesn't perform calculations itself (regardless of the number of data series you use).

All a variable series does is storing a value. So if that's what you're using in the code, then no, MultiCharts .NET cannot recognise that you want `m_avg.Value` computed on the second data series. Or is `m_avg` perhaps an instance of a moving average function?

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 33 times

Re: syntax question  [SOLVED]

Postby darob » 15 Nov 2016

Thanks for the reply Josh. I've just scripted the following in StartCalc(): m_averagefc1.price = BarsOfData(2).Close; so now m_avg.Value references the right data series. Woke up before 5 with the answer ringing in my head :idea:

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

Re: syntax question

Postby JoshM » 16 Nov 2016

I've just scripted the following in StartCalc(): m_averagefc1.price = BarsOfData(2).Close; so now m_avg.Value references the right data series. Woke up before 5 with the answer ringing in my head :idea:
That's indeed the correct approach to calculate a function on a different data series. What a good way to wake up! (Might be a bit earlier though :o). Glad you got it fixed.


Return to “MultiCharts .NET”