Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Bug in NT8 export

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

    Bug in NT8 export

    Hi.
    this attached file is exported file from nt.
    however, seems NT exports it incorrectly, because during import, we get these messages:



    on those lines (in exported .cs file), I see such mistaked codes:

    line 34:
    Code:
    private VolumeRatiosBonus.LiveNewsBroadCast_namespace3{.LiveNewsBroadCast[] cacheLiveNewsBroadCast;



    the original source of indicator (that seems to cause the problem), is like:


    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml;
    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.DrawingTools;
    using System.Drawing;
    
    using SharpDX.Direct2D1;
    using SharpDX;
    using SharpDX.DirectWrite;
    using System.Net.Http;
    using System.Collections.Specialized;
    using System.Reflection; 
     
    using NinjaTrader.NinjaScript.Indicators.VolumeRatiosBonus.LiveNewsBroadCast_my_namespace;  
    
    namespace NinjaTrader.NinjaScript.Indicators.VolumeRatiosBonus.LiveNewsBroadCast_my_namespace{
    	#region NewsImpact Enum
    	public enum NewsImpact	
    	{
    	    Unknown = 0,
    	    Error 	= 1
    	}
    	#endregion
    }
    
    
    namespace NinjaTrader.NinjaScript.Indicators.VolumeRatiosBonus
    {
    	public class LiveNewsBroadCast : Indicator
    	{
    
    		
    		//.......
    	}
    }
    if i put space between "LiveNewsBroadCast_my_namespace" and "{", then another error appears (in bottom auto-generated code:



    i have met the problem quite frequently, when i declare and use "using" command with embeded helper namespaces, in case i use them like:

    Code:
    VolumeRatiosBonus.LiveNewsBroadCast_my_namespace;
    instead of

    Code:
    NinjaTrader.NinjaScript.Indicators.VolumeRatiosBonus.LiveNewsBroadCast_my_namespace;
    obviously , compiler uses some imperfect methods, and it needs to be fixed.


    if i move `namespace NinjaTrader.NinjaScript.Indicators.VolumeRatiosBon us.LiveNewsBroadCast_my_namespace{` declaration (line) below the main indicator namespace block, then problem is completely fixed and everything does as it should work (even export is ok).
    Attached Files
    Last edited by ttodua; 04-13-2018, 12:31 PM.

    #2
    Hello. Thank you for the post.

    Using a fully qualified namespace will give scope to whatever namespace you are calling from. You can use a namespace alias to help make the code less verbose:



    I'm not sure if I have the full context here, but it looks like you are trying to access something from an external namespace and do not give the fully qualified name, then you will run into scoping issues.

    Legal:

    Code:
    namespace MainNS
    {
    
            namespace SubNS
            {
                    class MyClass;
            }
    
            class MainClass
            {
                   SubNS.MyClass myNewClass;
            }
    
    }
    Not legal:

    Code:
    namespace NS1
    {
        namespace MyClassNS
        {
            class MyClass {}
        }
    }
    
    namespace MainNS
    {
        using NS1;
        class MainClass
        {
            MyClassNS.MyClass myNewClass;
        }
    }
    If you want to do this in the way the second sample demonstrates, then make a namespace alias to fully qualify the type.

    Please let us know if we may be of any further assistance.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    19 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    179 views
    0 likes
    Last Post jeronymite  
    Started by ghoul, Today, 06:02 PM
    0 responses
    9 views
    0 likes
    Last Post ghoul
    by ghoul
     
    Started by DanielSanMartin, Yesterday, 02:37 PM
    2 responses
    13 views
    0 likes
    Last Post DanielSanMartin  
    Started by DJ888, 04-16-2024, 06:09 PM
    4 responses
    13 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Working...
    X