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 sn0z33r, 02-12-2025, 09:37 AM
    5 responses
    25 views
    0 likes
    Last Post sn0z33r
    by sn0z33r
     
    Started by gustavobp, Today, 03:15 AM
    0 responses
    5 views
    0 likes
    Last Post gustavobp  
    Started by gustavobp, Today, 03:00 AM
    0 responses
    5 views
    0 likes
    Last Post gustavobp  
    Started by nicbizz, Today, 02:14 AM
    0 responses
    5 views
    0 likes
    Last Post nicbizz
    by nicbizz
     
    Started by Ringer13, Today, 01:59 AM
    0 responses
    9 views
    0 likes
    Last Post Ringer13  
    Working...
    X