Often we need use indicators in other indicator plots calculation. We do this different ways. Wich is right or economic in point of memory usage:
1.Usage:
OnBarUpdate()
MACD macd = MACD(Input, 12, 26, 5);
MyPlot.Set(macd[0] * macd[1]);
2.Usage:
OnBarUpdate()
MyPlot.Set(MACD(Input, 12, 26, 5)[0] * MACD(Input, 12, 26, 5)[1]);
3.Usage:
Variables
MACD macd = null;
Initialize()
MACD macd = MACD(Input, 12, 26, 5);
OnBarUpdate()
MyPlot.Set(macd[0] * macd[1]);
Also for all usage types tell me please, what is mean use with and without new directive? I mean, for example for 1.Usage, what is the difference above and below 1.Usage sample:
1.Usage with new directive:
OnBarUpdate()
MACD macd = new MACD(Input, 12, 26, 5);
MyPlot.Set(macd[0] * macd[1]);
PS:I have an indicator and it has 2 parameters, and when i want to use it other indicator OnBarUpdate method, if i don't write new i receive an error. I think Ninja don't decide wich constructor must be use:
MyOtherIndicator OnBarUpdate()
MyIndicator myIndicator = new MyIndicator();
Plot.Set(myIndicator[0]);
If i write like this I receive an error:
MyOtherIndicator OnBarUpdate()
MyIndicator myIndicator = MyIndicator(); /// There is no constructor witout parameter
Plot.Set(myIndicator[0]);
Please explain me all usages and samples means separately.
Thanks...
Comment