Organising and nesting variables in functions?  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
jarym
Posts: 58
Joined: 16 Feb 2015
Has thanked: 14 times
Been thanked: 6 times

Organising and nesting variables in functions?

Postby jarym » 25 Mar 2015

Hi,

I am wondering if its possible to nest complex objects inside of a VariableSeries or VariableObject, with each nested object containing its own members of VariableSeries or VariableObject type.

My use case:
I have an indicator - let's call it MyIndicator and I need to store a lot of repeating information. I could put each item as a member in MyIndicator. However, if I want to stick to Object Oriented concepts then it makes more sense to group these variables in a struct or class.

So instead of having:
class MyIndicator {
VariableSeries<int> HiPi_A_Bars
VariableSeries<double> HiPi_A_Price
VariableSeries<double> HiPi_A_Reg
VariableSeries<int> HiPi_B_Bars
VariableSeries<double> HiPi_B_Price
VariableSeries<double> HiPi_B_Reg
}

I would like something like
class MyIndicatorInfo {
VariableSeries<int> Bars
VariableSeries<double> Price
VariableSeries<double> Reg
}

class MyIndicator {
VariableObject<MyIndicatorInfo> HiPi_A
VariableObject<MyIndicatorInfo> HiPi_B
}


Is this possible? I'm not sure how I would declare 'MyIndicatorInfo' so that the VariableSeries members would be managed by MC.NET.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Organising and nesting variables in functions?  [SOLVED]

Postby Henry MultiСharts » 27 Mar 2015

Hello jarym,

Yes, that is possible to do that. Please find sample code attached.
Attachments
ClassVariables.pln
(1.28 KiB) Downloaded 529 times

jarym
Posts: 58
Joined: 16 Feb 2015
Has thanked: 14 times
Been thanked: 6 times

Re: Organising and nesting variables in functions?

Postby jarym » 27 Mar 2015

Exactly what I wanted - thank you!


Return to “MultiCharts .NET”