Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Hide / Unhide parameters in Strategy Analizer

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

    Hide / Unhide parameters in Strategy Analizer

    Hi

    I can't get work case number 1 from "SampleIndicatorTypeConverter" example when put into my strategy.

    The bool "Activate" can't being recognized. I just want to hide V1 and V2 after "Activate" box is selected in Strategy Analyzer Parameters.

    Sorry for asking but I being working on it all day long and I get stuck every time

    Best regards,

    Fernando



    (hashtag)region Properties

    [RefreshProperties(RefreshProperties.All)]
    [Display(ResourceType = typeof(Custom.Resource), Name = "ON/Off", GroupName = "Parameters", Order = 1)]
    public bool Activate
    { get; set; }

    [Range(0, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Variable 1", GroupName = "Parameters", Order = 2)]
    public int V1
    { get; set; }

    [Range(0, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Variable 2", GroupName = "Parameters", Order = 3)]
    public int V2
    { get; set; }

    #endregion


    public class MyConverter : StrategyBaseConverter
    {
    public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attrs)
    {
    PropertyDescriptorCollection propertyDescriptorCollection = base.GetPropertiesSupported(context)
    ? base.GetProperties(context, component, attrs)
    : TypeDescriptor.GetProperties(component, attrs);

    PropertyDescriptor v1 = propertyDescriptorCollection["V1"];
    PropertyDescriptor v2 = propertyDescriptorCollection["V2"];

    propertyDescriptorCollection.Remove(v1);
    propertyDescriptorCollection.Remove(v2);

    if (Activate)
    {
    propertyDescriptorCollection.Add(v1);
    propertyDescriptorCollection.Add(v2);
    }
    return propertyDescriptorCollection;
    }
    public override bool GetPropertiesSupported(ITypeDescriptorContext context)
    { return true; }
    }​

    #2
    Hello fercho,

    Unfortunately, typeconverters do not work in the Strategy Analyzer.

    In order for a property to be optimizable, we need to use the NinjaScriptProperty attribute. This does not play nicely when using a TypeConverter to customize property grid behavior:
    1. Even if a property is toggled off, it will still display in the Settings Display
    2. Applying NinjaScriptProperty attribute to toggling property breaks toggling behavior.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by johnMoss, Yesterday, 08:56 PM
    2 responses
    20 views
    0 likes
    Last Post johnMoss  
    Started by michelz, Yesterday, 08:30 AM
    5 responses
    44 views
    0 likes
    Last Post MiCe1999  
    Started by ntbone, Yesterday, 01:50 AM
    13 responses
    56 views
    0 likes
    Last Post MiCe1999  
    Started by gyilaoliver, Today, 10:30 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Irukandji, Yesterday, 04:24 PM
    2 responses
    27 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Working...
    X