Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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,
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Waxavi, Today, 02:10 AM
        0 responses
        3 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        8 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Working...
        X