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 CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    52 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    29 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    194 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    355 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    274 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X