pass values ​​between classes

Questions about MultiCharts .NET and user contributed studies.
shivax
Posts: 90
Joined: 02 Sep 2013
Has thanked: 37 times

pass values ​​between classes

Postby shivax » 11 Aug 2014

I'm developing an indicator that works in this way :

public class Indicator : IndicatorObject

private Function.M1 Funct1;

private Function.M2 Funct2;


protected override void Create() {
Funct1 = new Function.M1(this);
Funct2 = new Function.M2(this);
}

protected override void CalcBar(){
Funct2.c=Funct1.Value; ((The return of the function is passed from Funct1 to Funct2)
plot1.Set(Funct2.Value);
(the function funct2 processes the data transmitted over and plots the return value)
}


i ask you this question:

This way of trasmission parameters using class is fast(using Update on every tick) then a single indicator way?

i set my program in this way to organize it well

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

Re: pass values ​​between classes

Postby Henry MultiСharts » 13 Aug 2014

Hello shivax,

Addition calls always require some time. Whether execution time will be affected or not depends on how your code is designed. If it is designed efficiently then transmission of parameters using class
will take insignificant time, compared to single indicator way.

shivax
Posts: 90
Joined: 02 Sep 2013
Has thanked: 37 times

Re: pass values ​​between classes

Postby shivax » 13 Aug 2014

but if I create variables that need to be read and modified by all classes (M1 and M2 in the above example)
This is the best choice or is better to use global variables.

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

Re: pass values ​​between classes

Postby Henry MultiСharts » 13 Aug 2014

Both solutions are working. It is up to you to decide which one is more optimal for you.


Return to “MultiCharts .NET”