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

The type or namespace name 'SoundConverter' does not exist in the namespace

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

    The type or namespace name 'SoundConverter' does not exist in the namespace

    I'm getting this Log Tab error when trying to export an indicator:

    Error compiling export assembly : error CS0234: The type or namespace name 'SoundConverter' does not exist in the namespace 'NinjaTrader.NinjaScript.Indicators' (are you missing an assembly reference?)

    I added this class with a custom name (SoundConverter_HammerCandlesticks) to the indicator:

    Code:
            // using System.IO; https://forum.ninjatrader.com/forum/ninjatrader-8/indicator-development/1172753-sound-files-dropdown-picker?p=1172766#post1172766
            public class SoundConverter_HammerCandlesticks : TypeConverter
            {
    
                public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
                {
                    if (context == null)
                    {
                        return null;
                    }
                    //List <string> list;
                    List <string> list = new List <string> ();
    
                    DirectoryInfo dir = new DirectoryInfo(NinjaTrader.Core.Globals.InstallDir+ "sounds");
    
                    FileInfo[] files= dir.GetFiles("*.wav");
    
                    foreach (FileInfo file in files)
                    {
                        list.Add(file.Name);
                    }
    
                    return new TypeConverter.StandardValuesCollection(list);
                }
    
                public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
                {
                    return true;
                }
            }
    ​
    I have this reference in the properties section:

    Code:
                    [NinjaScriptProperty]
                    [Display(Name="Inverted Hammer Sound", Order=2, GroupName="01. Select Sound")]
                    [TypeConverter(typeof(NinjaTrader.NinjaScript.Indicators.SoundConverter))]
                    public string SoundFilesIHBrush
                    {get;set;}​
    I also have the same class with the original name in another indicator.

    I also have it in other indicators with other custom class names and those also do throw the same error when trying exporting them.

    I add the class to each indicator requiring it so as not to need looking for it years later.

    How can this indicator be exported without the compile error problem?
    Last edited by PaulMohn; 12-20-2023, 07:12 PM.

    #2
    Originally posted by PaulMohn View Post
    I added this class with a custom name (SoundConverter_HammerCandlesticks) to the indicator:

    I have this reference in the properties section:

    Code:
    [NinjaScriptProperty]
    [Display(Name="Inverted Hammer Sound", Order=2, GroupName="01. Select Sound")]
    [TypeConverter(typeof(NinjaTrader.NinjaScript.Indicators.SoundConverter))]
    public string SoundFilesIHBrush
    {get;set;}​
    Well, for starters, shouldn't this line,
    Code:
    [TypeConverter(typeof(NinjaTrader.NinjaScript.Indicators.SoundConverter))]
    actually be this?
    Code:
    [TypeConverter(typeof(NinjaTrader.NinjaScript.Indicators.SoundConverter_HammerCandlesticks))]

    Comment


      #3
      Originally posted by PaulMohn View Post
      I added this class with a custom name (SoundConverter_HammerCandlesticks) to the indicator:

      How can this indicator be exported without the compile error problem?
      Not sure you are aware, but there is a new NinjaTrader 8 standard way
      of doing this -- no longer do you need the TypeConverter code you're
      trying to fix.

      The new way is summarized as the FilePathPicker way.

      To get a dropdown in the property grid that returns the user's selected
      sound file, all you need is 2 lines of code,

      Code:
      [PropertyEditor("NinjaTrader.Gui.Tools.FilePathPicker", Filter="WAV Files (*.wav)|*.wav")]
      public string AlertSoundFile { get; set; }
      Study the indicator file @TrendLines.cs, which uses this technique.

      Just my 2˘.







      Comment


        #4
        Originally posted by bltdavid View Post

        Well, for starters, shouldn't this line,
        Code:
        [TypeConverter(typeof(NinjaTrader.NinjaScript.Indicators.SoundConverter))]
        actually be this?
        Code:
        [TypeConverter(typeof(NinjaTrader.NinjaScript.Indicators.SoundConverter_HammerCandlesticks))]
        Just what was needed. Thanks a lot bltdavid !

        I thought I tested it but then realized I only did to one of the these and doing it to all fixed it.

        Comment


          #5
          Originally posted by bltdavid View Post

          Not sure you are aware, but there is a new NinjaTrader 8 standard way
          of doing this -- no longer do you need the TypeConverter code you're
          trying to fix.

          The new way is summarized as the FilePathPicker way.

          To get a dropdown in the property grid that returns the user's selected
          sound file, all you need is 2 lines of code,

          Code:
          [PropertyEditor("NinjaTrader.Gui.Tools.FilePathPicker", Filter="WAV Files (*.wav)|*.wav")]
          public string AlertSoundFile { get; set; }
          Study the indicator file @TrendLines.cs, which uses this technique.

          Just my 2˘.






          Thanks for that reference. I'll test it asap!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Segwin, 05-07-2018, 02:15 PM
          14 responses
          1,789 views
          0 likes
          Last Post aligator  
          Started by Jimmyk, 01-26-2018, 05:19 AM
          6 responses
          837 views
          0 likes
          Last Post emuns
          by emuns
           
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          6 responses
          3,293 views
          1 like
          Last Post jgualdronc  
          Started by Touch-Ups, Today, 10:36 AM
          0 responses
          13 views
          0 likes
          Last Post Touch-Ups  
          Started by geddyisodin, 04-25-2024, 05:20 AM
          11 responses
          63 views
          0 likes
          Last Post halgo_boulder  
          Working...
          X