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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        38 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        287 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        288 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        134 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        95 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X