Simple example: Suppose I write my own version of, say, the StdDev indicator. I call it MyStdDev. I store intermediate calculations in public variables; e.g. the arithmetic mean is a public variable called 'mean'.
I can call MyStdDev(myseries, length) from another indicator or strategy, and it returns a result. Fine. But that's not all I want to do. I want to access the public variables in it too.
My question is, how do I access the other public values in MyStdDev?
I was thinking I have to do the following in my calling code:
[variables]
private MyStdDev MyObj; // declare an object of my indicator class
[Initialize]
MyObj = new MyStdDev(); // create a unique instance of the indicator
[OnBarUpdate]
double sd = MyObj(Close, Period)[0]; // same parameters as MyStdDev
double mn = MyObj.mean; // get the public value in the indicator
The compiler complains where I try to call MyObj with parameters. It says 'NonjaTrader.Indicator._MyStdDev.MyObj' is a 'field' but is used like a 'method'. The error code CS0118 says I'm using parentheses where I should be using brackets.
OK, so maybe I need to pass the parameters during initialization instead. But when I do that, I get an error CS1501, No overload for method 'MyStdDev' takes '2' arguments. But MyStdDev does have such a method.
I don't know what to do from this point. Suggestions? Am I making this problem more complicated than it really is, or not complicated enough?
-Alex
Comment