I want to be sure I understand how NT (v7) loads custom indicators. Let's say I create a new indicator in NT called foo() that takes a single integer parameter. Since indicator parameters are private class variables, it would seem NT would have to create a new instance of the class foo for every time every time it appears in code.
Secondly, I would expect NT only creates one instance of an indicator class per usage per chart over the lifetime of the chart (which "restarts" if you recalc the NinjaScript, etc.).
Let's say I have a second indicator bar, and the OnBarUpdate() method of this second indicator bar includes the following:
Plot0.Set(foo(14)[0]);
Plot1.Set(foo(21)[0]);
For a given use of the indicator bar, when CurrentBar == 0, at that point (or earlier) does NT create two instances of foo that live for the life of the indicator, or, does NT create a new instance of foo each time CurrentBar is called? If if it's the first scenario, which I would guess it is for the sake of efficiency, if I put two instances of the indicator bar on a chart, does that then mean that NT news up two instances of bar and therefore four instances of foo?
The reason I need to be sure is that I want to be certain that the state of private variables in my indicator classes is not overwritten by other uses of the indicator and that the state persists between calls to OnBarUpdate.
Thanks,
Gordon
Comment