Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StrategyAnalyzer not operating properly

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

    StrategyAnalyzer not operating properly

    I have been trying to get one of my strategies to work in SA and have been unable to do so. It's never taking entries although it's doing it fine on my chart. COBC is set to true so it should work. Anyway, I'm seeing something very strange which may be related. Please try to run the following test strategy to replicate the issue:

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        /// Enter the description of your strategy here
        /// </summary>
        [Description("Enter the description of your strategy here")]
        public class SATest : Strategy
        {
            #region Variables
            // Wizard generated variables
            private int myInput0 = 1; // Default setting for MyInput0
            // User defined variables (add any user defined variables below)
            #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()
            {
                CalculateOnBarClose = true;
    			String instrumentName = Instrument.MasterInstrument.Name; // Instruments[0].FullName.Substring(1); 
    			Print("Instrument Name: " + instrumentName);
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
            }
    
            #region Properties
            [Description("")]
            [GridCategory("Parameters")]
            public int MyInput0
            {
                get { return myInput0; }
                set { myInput0 = Math.Max(1, value); }
            }
            #endregion
        }
    }
    When I run this in my SA against the EURUSD for instance I get the following output:

    Instrument Name: EURUSD
    Instrument Name: USDCAD

    I thought maybe there's something wrong with my dev setup and I tried it on my live production box and got the very same! What's going on here?

    #2
    Hello molecool,

    Thank you for your post.

    What instrument are you testing this on in the Strategy Analyzer? Do you have an instrument list with both of these instruments? Do you have any messages in the Log tab after running the strategy in the Strategy Analyzer?

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello molecool,

      Thank you for your post.

      What instrument are you testing this on in the Strategy Analyzer? Do you have an instrument list with both of these instruments? Do you have any messages in the Log tab after running the strategy in the Strategy Analyzer?
      I was just running this on the EURUSD - I have an instrument list but it contains a lot more symbols than those two. No messages at all in the log tab. Have you tried the test on your end?

      Comment


        #4
        Hello molecool,

        Thank you for your patience.

        In my testing the print will be of the that last set instrument in my previous tests or the first instrument in the instrument list. If I make my default instrument list only the one instrument I am testing, of course it only prints this instrument but twice. The reason behind this, I am unaware of. I will check with my colleagues on this tomorrow.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello molecool,

          Thank you for your patience.

          In my testing the print will be of the that last set instrument in my previous tests or the first instrument in the instrument list. If I make my default instrument list only the one instrument I am testing, of course it only prints this instrument but twice. The reason behind this, I am unaware of. I will check with my colleagues on this tomorrow.
          On yet another system I have it was the last instrument as well. On two of my systems it's the AUDCAD - probably because they both have a similar instrument list (it's not the last one though). What's interesting is that I see certain initiate routines being run on that very pair as well during charting. This must be something with the latest version because I don't recall seeing this behavior in the past few years.

          Comment


            #6
            Hello molecool,

            Unfortunately, printing in the Initialize() will produce this result no matter what. But if you use OnStartUp() then the print would only occur once: http://www.ninjatrader.com/support/h.../onstartup.htm

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Hello molecool,

              Unfortunately, printing in the Initialize() will produce this result no matter what. But if you use OnStartUp() then the print would only occur once: http://www.ninjatrader.com/support/h.../onstartup.htm
              I guess at this point it's cosmetic. What I was worried about was it interfering with my StrategyAnalyzer - had no luck getting it work for some reason.

              Comment

              Latest Posts

              Collapse

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