NinjaTrader Support Forum  

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

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

Reply
 
Thread Tools Display Modes
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
Old 02-15-2011, 07:25 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

saltminer, can you perhaps send us the indicator to test including the trace you got to support at ninjatrader dot com? Currently I see no reason why it should behave like you experienced here...

Thanks,
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-15-2011, 11:57 PM   #3
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 164
Thanks: 2
Thanked 3 times in 3 posts
Default

I removed and reinstalled Ninja (including a brand new user folder) to use the developer beta version of CliSecure. I had also had a strange problem with the built in Woodies indicator causing a strategy not to compile.
Got that fixed, and now the indicator with the code below is working fine!
Blame it on poltergeists.
Thanks for the always prompt support.
saltminer
saltminer is offline  
Reply With Quote
Old 02-16-2011, 07:38 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

You're welcome, thanks for reporting back - I'm glad to hear all is well now.
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

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 06:22 PM.