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 DoomNM, Today, 01:12 AM
    0 responses
    6 views
    0 likes
    Last Post DoomNM
    by DoomNM
     
    Started by kalalex, Yesterday, 01:31 AM
    2 responses
    25 views
    0 likes
    Last Post AndyM
    by AndyM
     
    Started by bxl2019, 03-16-2025, 12:34 PM
    3 responses
    22 views
    0 likes
    Last Post Leeroy_Jenkins  
    Started by Hilltree, Yesterday, 09:00 AM
    2 responses
    16 views
    0 likes
    Last Post Hilltree  
    Started by samish18, Yesterday, 06:46 PM
    0 responses
    10 views
    0 likes
    Last Post samish18  
    Working...
    X