Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Crashing NInja with multiple BarsArray moving averages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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, 02:44 AM.

    #2
    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,

    Comment


      #3
      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

      Comment


        #4
        You're welcome, thanks for reporting back - I'm glad to hear all is well now.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X