NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 02-14-2011, 11:38 PM   #1
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 164
Thanks: 2
Thanked 3 times in 3 posts
Default Crashing NInja with multiple BarsArray moving averages

Hi guys,
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:
Code:
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;    
            }
ma_number is sent as a parameter to the Method; basically it just selects BarsArray[1] or BarsArray[2].

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
Last edited by saltminer; 02-15-2011 at 01:44 AM.
saltminer is offline  
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Moving averages deanldavis475 Indicator Development 1 12-09-2010 09:55 AM
Two moving averages indicator. germano Indicator Development 2 01-04-2010 05:25 AM
Displaced moving averages ggloor Charting 6 10-11-2009 02:11 AM
Three moving averages germano Indicator Development 2 07-24-2009 12:39 PM
Displaced moving averages T2020 Charting 2 01-20-2009 09:13 AM


All times are GMT -6. The time now is 09:49 PM.