Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy is not run in Analyzer

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

    Strategy is not run in Analyzer

    Strategy name is shown in Backtest strategy list. But after I click "run backtest", Analyzer run strategy, that was chosen before, but not I have chosen last. I saw that "Label" field didn't change after I chosen last strategy. What is it?
    Compiling shown strategy is OK.

    Code:
       
    [Description("LW Momentum Pivot ws")]
        public class LWMPws : Strategy
        {
            #region Variables
    		//periods for ATR_big
    		private int aTR_big_per = 14;
    		private double EntryATR;
            #endregion
    
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
    			ATR(ATR_big_per).Plots[0].Pen.Color = Color.Blue;
                Add(ATR(ATR_big_per));
    			EntryATR = ATR(ATR_big_per)[1];
    			
    			
    			
    			CalculateOnBarClose = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Checks to ensure all Bars objects contain enough bars before beginning
    
         		if (CurrentBars[0] <= BarsRequired)
             		return;
    	
    			
                   // Condition for short
                	if (Close[2] > Close[3] + 1 * TickSize && Close[1] < Close[2] + 1 * TickSize && Close[2] > MAX(Close,5)[2]) 
                		{
                    	EnterShortStop(DefaultQuantity, Close[1] - EntryATR, "Short Entry");
                		}				
         		
    	
    				// Condition for long
    				if (Close[2] < Close[3] + 1 * TickSize && Close[1] > Close[2] + 1 * TickSize && Close[2] < MIN(Close,5)[2])
    			{
    				EnterLongStop(DefaultQuantity, Close[1] + EntryATR, "Long Entry");
    			}
    			
                
    			
    			SetProfitTarget("Long Entry", CalculationMode.Price, EntryATR);
    			SetStopLoss("Long Entry", CalculationMode.Price, EntryATR, false);
    			
    			SetProfitTarget("Short Entry", CalculationMode.Price, EntryATR);
    			SetStopLoss("Short Entry", CalculationMode.Price, EntryATR, false);
    			
    		
            }
    
            #region Properties
            [Description("Periods for ATR_big")]
            [GridCategory("Parameters")]
            public int ATR_big_per
            {
                get { return aTR_big_per; }
                set { aTR_big_per = Math.Max(1, value); }
            }  
    		
            #endregion
        }
    }
    Only Trace file sees ERROR

    1. ERROR: Failed to call method 'Initialize' for strategy 'LWMPws/5e54a411d1b14f9e921192306f114233': В экземпляре объекта не задана ссылка на объект.
    From Russian this will be "In an instance of Object reference not set to an object." (translated via Google).

    2. Code.Editor.OnLoad: Failed to reference 'NinjaTrader.Custom, Version=7.0.1000.15, Culture=neutral, PublicKeyToken=null': System.IO.FileNotFoundException: Не найден указанный модуль. (Исключение из HRESULT: 0x8007007E)
    в System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
    в System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
    в System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
    в System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
    в System.Reflection.Assembly.LoadFrom(String assemblyFile)
    в NinjaTrader.Code.Editor.OnLoad(Object sender, EventArgs e)
    Last edited by alexstox; 09-22-2013, 09:34 AM.

    #2
    Hello alexstox,

    Thank you for your post.

    Your EntryATR is referencing a barsAgo index of 1, this cannot be referenced in the Initialize() method. Place this in the OnBarUpdate() method instead:
    Code:
            protected override void OnBarUpdate()
            {
    			EntryATR = ATR(ATR_big_per)[1];
    Please let me know if I may be of further assistance.

    Comment


      #3
      All errors from Trace file after correction:
      2013-09-22 20:10:17:077 WARNING: Session Break (Version 7.0.1000.15)
      2013-09-22 20:08:06:757 ERROR: Unable to restore strategy 'NinjaTrader.Strategy.LWMPadviser' with ID 'a46d1e999db8467ca63838dd71036be2'. Most likely this strategy no longer is supported by the custom assemblies.
      2013-09-22 20:08:06:827 ERROR: Unable to restore strategy 'NinjaTrader.Strategy.LWMPadviser' with ID 'd3352d7a60d049acbbb778874080072c'. Most likely this strategy no longer is supported by the custom assemblies.

      After trying to run the strategy in the Analyzer:
      the same as above and
      ERROR: Error on calling 'OnBarUpdate' method for strategy 'LWMPws/ab76b6e1faab450e866233841ac7b35a': Индекс находился вне границ массива.
      From Google translate: Index was outside the bounds of the array

      Last edited by alexstox; 09-22-2013, 02:33 PM.

      Comment


        #4
        Hello alexstox,

        Thank you for your response.

        The following message can be ignored as it is only indicating that the strategy is missing from a file such as a workspace:
        ERROR: Unable to restore strategy 'NinjaTrader.Strategy.LWMPadviser' with ID 'a46d1e999db8467ca63838dd71036be2'. Most likely this strategy no longer is supported by the custom assemblies.
        The following would indicate you need to ensure you have enough bars on your chart before accessing their values in your code:
        ERROR: Error on calling 'OnBarUpdate' method for strategy 'LWMPws/ab76b6e1faab450e866233841ac7b35a': Индекс находился вне границ массива.
        From Google translate: Index was outside the bounds of the array
        Please review the following link for information on making sure you have enough bars before accessing them: http://www.ninjatrader.com/support/f...ead.php?t=3170

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,227 views
        0 likes
        Last Post xiinteractive  
        Started by andrewtrades, Today, 04:57 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        7 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        440 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        12 views
        0 likes
        Last Post FAQtrader  
        Working...
        X