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

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 prisonbreaker82, 02-24-2024, 11:16 AM
    2 responses
    33 views
    0 likes
    Last Post proptradingshop  
    Started by geotrades1, Today, 07:54 AM
    1 response
    5 views
    0 likes
    Last Post geotrades1  
    Started by MGHORBEL, Today, 06:25 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by 1001111, Today, 01:35 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by tradingnasdaqprueba, Yesterday, 03:42 AM
    11 responses
    40 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X