Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

V8 ignores some attributes

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

    V8 ignores some attributes

    This code is a complete self-contained indicator. When compiled it will appear in the indicators list in the Indicators dialog. When chosen, its one boolean parameter will be displayed. There are two problems:

    1) The [Default ...] attribute has no effect. In V7 there was an indication when a user changed from the default value. To date I have never seen that work in V8, including in cases like this one where a default value is clearly specified. I believe I have reported this in the past, but I am bringing it up again because this trivial code sample shows the problem.

    2) More seriously, the [TypeConverter ...] has no effect. I ran it with Visual Studio and put breakpoints on the type converter's 4 functions and none of them ever got called. As a result, this property gets displayed as a check box. Because of the type converter, it is supposed to be displayed as one of two strings -- "Enable" or "Disable". This works in Version 7, but has never worked in Version 8. I believe I have reported this one in the past, too, but I am bringing it up again because this trivial code sample shows the problem.

    If anyone sees a problem with the code, by all means let me know.

    Thanks,
    EV

    Code:
        // //////////////////////////////////////////////////////////////////////////////////
        //
        // This test program illustrates two bugs in NinjaTader Version 8
        //        1) The [DefaultValue ...] attribute has not effect
        //        2) The [TypeConverter ...] attribute has no effect
        //            * Debugger breakpoints show the type converter is never even called
        //
        // //////////////////////////////////////////////////////////////////////////////////
    
    
    using System;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    
    //This namespace holds Indicators in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class AATypeConverterTest : Indicator
        {
            // ///////////////////////////////////////////////////////////////////////////////////////////////////
            // Boolean property that should be displayed in the Indicators dialog as a string
            private bool enableTickerData = true;
            [DefaultValue(typeof(bool), "true")]
            [TypeConverter(typeof(EnableDisableConverter))]
            [Browsable(true)]                               // Do show in the indicator property dialog
            [Display(Order = 0, Name = "Test", Description = "Test an Enable/disable property")]
            public bool EnableTickerData
            {
                get { return enableTickerData; }
                set { enableTickerData = value; }
            }
        
            // ///////////////////////////////////////////////////////////////////////////////////////////////////
            // Type converter for bool values to ("On" or "Off") or else ("Yes" and "No")
            class EnableDisableConverter : BooleanConverter
            {
                public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
                    { return (destinationType == typeof(string)) ? true : base.CanConvertTo(context, destinationType); }
                public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
                    { return (bool)value ? "Enable" : "Disable"; }
                    
                public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
                    { return true; }                                // "false" makes the string non-editable
                public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
                    { return (string)value == "Enable"; }
            }    
        }
    }

    #2
    I am running this scenario by development to see if we can support this implementation or if there is anything we can offer you as a workaround.

    I will get back to you once I have heard from development.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks, Matthew

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Perr0Grande, Today, 08:16 PM
      0 responses
      2 views
      0 likes
      Last Post Perr0Grande  
      Started by elderan, Today, 08:03 PM
      0 responses
      5 views
      0 likes
      Last Post elderan
      by elderan
       
      Started by algospoke, Today, 06:40 PM
      0 responses
      10 views
      0 likes
      Last Post algospoke  
      Started by maybeimnotrader, Today, 05:46 PM
      0 responses
      12 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      7 views
      0 likes
      Last Post quantismo  
      Working...
      X