Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8b9 NS wrapper doesn't see enums declared in "folder" namespaces

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

    NT8b9 NS wrapper doesn't see enums declared in "folder" namespaces

    If you declare public enum in "folder" namespace ,eg.:
    Code:
    [FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#000000] NinjaTrader.NinjaScript.Indicators.Development[/COLOR][/SIZE][/FONT]
    [SIZE=2][FONT=Consolas]{[/FONT][/SIZE]
    [/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]  public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]enum [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]MarkerType[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]  {[/SIZE][/FONT]
    [SIZE=2][FONT=Consolas]      None,[/FONT][/SIZE]
    [SIZE=2][FONT=Consolas]      BackBrush,[/FONT][/SIZE]
    [SIZE=2][FONT=Consolas]      Arrow,[/FONT][/SIZE]
    [SIZE=2][FONT=Consolas]      Triangle,[/FONT][/SIZE]
    [SIZE=2][FONT=Consolas]      Diamond[/FONT][/SIZE]
    [SIZE=2][FONT=Consolas]  }[/FONT][/SIZE]
    [SIZE=2][FONT=Consolas]}[/FONT][/SIZE]
    [/SIZE][/FONT]
    and then try to add property using this enum inside the same namespace/indicator, eg:

    Code:
    [[FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]NinjaScriptProperty[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]][/SIZE][/FONT]
    [SIZE=2][FONT=Consolas][[/FONT][/SIZE][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Display[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2](Name = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"MarkEntryBy"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], Description = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Mark Entry By"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], Order = 3, GroupName = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Parameters"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2])][/SIZE][/FONT]
    [/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]MarkerType[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] MarkEntryBy[/SIZE][/FONT]
    [SIZE=2][FONT=Consolas]{ [/FONT][/SIZE][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]; [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]; }[/SIZE][/FONT][/SIZE][/FONT]
    It will not compile since the wrapper doesn't see the enum.
    To make it work you need to provide full path in the property:
    Code:
    [FONT=Consolas][SIZE=2][SIZE=2][FONT=Consolas][[/FONT][/SIZE][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]NinjaScriptProperty[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]][/SIZE][/FONT]
    [SIZE=2][FONT=Consolas][[/FONT][/SIZE][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Display[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2](Name = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"MarkEntryBy"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], Description = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Mark Entry By"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], Order = 3, GroupName = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Parameters"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2])][/SIZE][/FONT]
    [/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] NinjaTrader.NinjaScript.Indicators.Development.[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]MarkerType[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] MarkEntryBy[/SIZE][/FONT]
    [SIZE=2][FONT=Consolas]{ [/FONT][/SIZE][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]; [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]; }[/SIZE][/FONT][/SIZE][/FONT]

    #2
    Hello,

    Thank you for the post on this.

    Could you provide a full sample of this, I am not able to reproduce any error when not using the fully quallified name in the current internal build.

    I would like to see the sample you have and try that in my installation to see if the error persists.


    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 03-03-2016, 03:19 PM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse.

      My concern is that the enum is placed in exactly the same namespace as the indicator that uses it. And that's the part that is very confusing especially that when you create an indicator from within a folder you are given a namespace for the indicator automatically. Adding enum to the same namespace as indicator, ie: just above:
      Code:
      public class MyIndicator: Indicator
      {
      ...
      }
      is the most intuitive.

      If an user gets an error message stating the enum couldn't be found even though it is in the same namespace he needs to understand how the wrapper works in order to fix it.

      Comment


        #4
        Hello,

        I was unable to produce the result you were, I believe I was doing the same test but to be certain could you attach a full sample of what is currently not working?

        In the internal build I did not get any errors, if I can test what you are it may be this is resolved or it may be we are not doing the same test.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Since it won't compile with an error here it is - paste the following into your indicator and compile:
          Code:
          #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.Data;
          using NinjaTrader.NinjaScript;
          using NinjaTrader.Core.FloatingPoint;
          using NinjaTrader.NinjaScript.DrawingTools;
          #endregion
          
          //This namespace holds Indicators in this folder and is required. Do not change it. 
          namespace NinjaTrader.NinjaScript.Indicators.Custom
          {
          	public enum Testing{ one, two, three}
          	public class EnumTest1 : Indicator
          	{
          		protected override void OnStateChange()
          		{
          			if (State == State.SetDefaults)
          			{
          				Description							= @"Enter the description for your new custom Indicator here.";
          				Name								= "EnumTest1";
          				Calculate							= Calculate.OnBarClose;
          				IsOverlay							= false;
          				DisplayInDataBox					= true;
          				DrawOnPricePanel					= true;
          				DrawHorizontalGridLines				= true;
          				DrawVerticalGridLines				= true;
          				PaintPriceMarkers					= true;
          				ScaleJustification					= NinjaTrader.Gui.Chart.ScaleJustification.Right;
          				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
          				//See Help Guide for additional information.
          				IsSuspendedWhileInactive			= true;
          			}
          			else if (State == State.Configure)
          			{
          			}
          		}
          
          		protected override void OnBarUpdate()
          		{
          			//Add your custom indicator logic here.
          		}
          		
                  #region Properties
          		[NinjaScriptProperty]
                  [Display(Name = "TestingIt", Description = "TestingIt", Order = 1, GroupName = "Parameters")]
                  public Testing TestingIt
                  { get; set; }
          		#endregion
          
          	}
          }

          Comment


            #6
            The exact steps to reproduce:
            1. Create folder in "Indicators", eg. "Custom"
            2. Right click on "Custom" -> New Indicator
            3. Add name of the indicator, eg. "EnumTest1" and Generate
            4. Add:
            Code:
            public enum Testing{ one, two, three}
            just above:
            Code:
            public class EnumTest1 : Indicator
            5. Add public property:
            Code:
            #region Properties
            [NinjaScriptProperty]
            [Display(Name = "TestingIt", Description = "TestingIt", Order = 1, GroupName = "Parameters")]
            public Testing TestingIt
            { get; set; }
            #endregion
            6. Compile

            Fails to find Testing every time on my end

            PS. In Hindsight after giving you exactly these steps "Custom" may not be the best idea for the name of the folder as it raises some other issues. But the error still holds for other name.
            Last edited by gregid; 03-03-2016, 04:03 PM.

            Comment


              #7
              Hello,

              Thank you for the more complete sample.

              One item specific with this sample is the namespace, this is hiding the Internal namespace Custom so it is causing additional error. Renaming the folder to something else and namespace seems to prevent the Custom.Resource errors this is giving.

              Regarding the NinjaScriptProperty usage, I do see the error when defined like this but is resolved when not using NinjaScriptProperty Or is resolved when using the fully qualified name. This would be expected as the wrapper code is being generated to allow the indicator to be used in multiple namespaces. In the code that is generated the exact enum name is used, so if you place the full name it would use the full name, otherwise if the short name is used it would use that which is invalid.

              Because of the nature of the wrapper code I would expect that this occurs without using the fully qualified name, I will work with product management on this to see if there can be further documentation on this subject. To resolve the question, a fully qualified name should be used in this situation to allow the compiler to correctly compile the wrapper code.

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

              Comment


                #8
                Yeah, "Custom" was just me being "creative", so just an accident while making a quick sample for you (as noticed in my PS in last post). I do not use the folder/namespace myself.

                Yes the error is only because NS wrapper while generating constructor for this specific indicator cannot find enum that should be part of this constructor (indicated by [NinjaScriptProperty] decorator.

                The way I would see it solved is for the wrapper generator to look for object in indicator's own namespace as well as default "NinjaTrader.NinjaScript.Indicators"... Well, I'll let you find a solution

                Thanks

                Comment


                  #9
                  I am afraid NS wrapper generator has some serious problems with namespaces.

                  I have just tried to use global qualifier to circumvent namespace conflict, eg:
                  Code:
                  [NinjaScriptProperty]
                  [Display(Name = "MarkEntryBy", Description = "Mark Entry By", Order = 1, GroupName = "Parameters")]
                  public global::g3.NinjaScript.Utility.MarkerType MarkEntryBy
                  { get; set; }
                  The result: the script compiles just fine but the generated wrapper completely removed this property from the constructor! I consider it a bug.

                  Overall I spent too much time trying to resolve wrapper quirks around namespaces for simple enums - here visible with enums but I fear these problems will show up someplace else.

                  Edit: BTW, I would think global qualifier should be used in generated code anyway to avoid potential conflicts.
                  Last edited by gregid; 03-04-2016, 05:47 AM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by algospoke, Yesterday, 06:40 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post algospoke  
                  Started by ghoul, Today, 06:02 PM
                  3 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by jeronymite, 04-12-2024, 04:26 PM
                  3 responses
                  45 views
                  0 likes
                  Last Post jeronymite  
                  Started by Barry Milan, Yesterday, 10:35 PM
                  7 responses
                  20 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  10 responses
                  181 views
                  0 likes
                  Last Post jeronymite  
                  Working...
                  X