Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Two namespaces in an indicator contained in a subfile error.

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

    Two namespaces in an indicator contained in a subfile error.

    Almost certainly already dealt with in a thread somewhere but I couldn't find one or a library reference.

    I have a master subfile inside the indicators list called j2. So the namespace is NinjaTrader.NinjaScript.Indicators.j2

    The indicator name is thus after this as a public class. There are a series of proprietary indicators that I keep in this subfolder j2

    I have two others that possess second namespaces that are specifically used for dropdown multiple choice public enums. I am unable to keep these in the j2 file as if placed there they will return compilation errors stating that the second namespace cannot be found. I thus have to keep them out of the j2 subfolder and instead have to keep them in the general indicators list.

    Specific Example: The following indicator construct section is currently kept in the general indicators file and everything works just fine:

    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;

    using j2LevelsBaseLine;
    #endregion


    namespace j2BaseLine
    { public enum BaseLine { Option1, Option2, Option3 }
    }

    //This namespace holds Indicators in this folder and is required. Do not change it.

    namespace NinjaTrader.NinjaScript.Indicators

    {

    public class j2Levels : Indicator

    Now if I simply add ".j2" to the second namespace & place it in the j2 subfolder i.e.
    namespace NinjaTrader.NinjaScript.Indicator
    s​.j2

    When compiling it will return an error stating that j2Levels cannot be found in the NinjaTrader.NinjaScript.Indicators​.j2

    First thought is that I have the enums namespace incorrectly placed or identified. Or is simply that if one is using two namespaces one cannot keep that indicator in a subfile of the indicators list?​​

    #2
    Hello johnMoss,

    Attached is a modified version of the SampleUniversalMovingAverage reference sample found from the Desktop SDK linked below.
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


    This modified version has the indicator in a custom namespace and the enum in a custom namespace. Note, the namespaces are different.
    SampleUniversalMovingAverage_NT8.zip

    "When compiling it will return an error stating that j2Levels cannot be found in the NinjaTrader.NinjaScript.Indicators​.j2​"

    Likely the auto generated code at the bottom of the script is referencing the previous path location. I typically recommend dragging and dropping the file into the folder in the NinjaScript Editor Explorer pane, or creating a new file within the folder in the Explorer pane and then writing or copying the code into the new file that has the proper namespace path.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X