Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

'NinjaTrader.Strategy' is a 'namespace' but is used like a 'type'

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

    'NinjaTrader.Strategy' is a 'namespace' but is used like a 'type'

    Hi There,

    This may be a bit of a beginner's question, but i'm trying to create my first strategy based on a custom indicator of my own design, and i keep getting this compilation error:

    'NinjaTrader.Strategy' is a 'namespace' but is used like a 'type'

    I've searched the forums for the last 30 mins about this, but can't find a solution.

    My Using declarations are:

    #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

    and right after that i have:

    namespace NinjaTrader.Strategy

    After that:

    public class myCustomStrategy : Strategy




    basically i've just taken the SampleMACrossOver strategy provided by NT, and put in the code from my indicator into the Initialize and OnBarUpdate sections, as well as the variables region, and removed the plot objects...

    Anything else i might be doing wrong? What does this error actually mean?

    Thanks!

    #2
    Hello,

    Thanks for the note.

    Without being able to see the full code I really couldn't comment unfortunately.

    Please send code to support at ninjatrader dot com ATTN: Brett and I can take a quick look see where the text error is.

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      Originally posted by MrOrange View Post
      Hi There,

      This may be a bit of a beginner's question, but i'm trying to create my first strategy based on a custom indicator of my own design, and i keep getting this compilation error:

      'NinjaTrader.Strategy' is a 'namespace' but is used like a 'type'

      I've searched the forums for the last 30 mins about this, but can't find a solution.

      My Using declarations are:

      #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

      and right after that i have:

      namespace NinjaTrader.Strategy

      After that:

      public class myCustomStrategy : Strategy




      basically i've just taken the SampleMACrossOver strategy provided by NT, and put in the code from my indicator into the Initialize and OnBarUpdate sections, as well as the variables region, and removed the plot objects...

      Anything else i might be doing wrong? What does this error actually mean?

      Thanks!
      If you double-clck on the error, the compiler should take you to the errant line. What is that line?

      Comment


        #4
        It was the namespace line, which i didn't see a problem with because well... i copied it right from the sample strategy. The problem turned out to be that i needed to have Unmanaged = true; in the initialize section. thanks for your help Brett!

        Comment


          #5
          Namespace error. Post the answer please.

          I too am getting the namespace error on every strategy I try and compile. I have even tried to compile the included MA CrossOver Strategy that came with NT. I have sent a email to support with screen shots and the code. It would be good if you could post the reason for the error in the forum, as I have been through all forums seeking the same answer with no luck. I can see if it was something I coded incorrectly but when I get the same thing using a NT Default Strategy then there is something wrong.

          Thanks Ninjas. I still give you guys a 10.

          Comment


            #6
            Hello,

            If you send email into support at ninjatrader dot com with screenshots then we will respond via emails.

            Let me know if you do not already have a response.
            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

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