I've got some code here that is called from BarsArray[0], calculating moving averages based on BarsArray[1] and BarsArray[2].
If I call it once, for only one of the timeframes, the code works fine. If I call it twice I get two messages, one the Ninja-has-to-quit crash message, and another saying the indicator cannot be serialised.
OnBarUpdate calls a method which does this:
switch (MAType) { case KashMTFMA_MAType1098.SMA: result = (SMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.EMA: result = (EMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.HMA: result = (HMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.LinReg: result = (LinReg(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.SMMA: result = (SMMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.TEMA: result = (TEMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.TMA: result = (TMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.VMA: result = (VMA(Closes[ma_number+1],MAPeriod, MAPeriod)[0]); break; case KashMTFMA_MAType1098.VWMA: result = (VWMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.WMA: result = (WMA(Closes[ma_number+1],MAPeriod)[0]); break; case KashMTFMA_MAType1098.Off: result = double.MinValue; break; }
If you can shed any light on why calling this twice would break Ninja, or can suggest another elegant 'correct' way to to achieve the same result of calculating multiple moving average types on multiple iDataSeries, please let me know.
Thanks,
saltminer
Comment