Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can I update value of an element in Configure Dialog, after value chg in dropdown ?

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

    Can I update value of an element in Configure Dialog, after value chg in dropdown ?

    Hello,

    I have an enum which displays a dropdown menu in the config dialog box.

    I wonder if there is a method that I can call to set the value of the name of the plot in the folded config dialog box after a change has been made in the dropdown?
    Please reference the attached screen capture.


    In my OBU section, I set the name of the plot , depending on the selected choice in the enum dropdown. i.e. Plots[0].Name = enum.value

    After the indicator has already been added to the chart, and I try to change a setting in the configure dialog, the value of Plot[0].name is set to the value previously configured, and it does not update after a change is made in the dropdown.

    But I use an override for DisplayName, and as soon as I make a change to the dropdown, the DisplayName in the Configured section of the dialog box is updated to match the selected choice in the dropdown.


    I have read, but have not seen, an explanation of the difference between SetDefaults and Configure AFTER an indicator has been added to the chart, and you are revisiting the config dialog box, to make a change to a parameter.

    I.e. It seems that Defaults have already been set because the indicator is already on the chart, so that state does nothing, and the Configure State doesn't get triggered until you click the OK or APPLY button. I was trying to sue those 2 stats to reset the name of the plot to a generic value, ie "Plot" so it did not reflect the name of the previous selected plot.

    Thank you



    #2
    Hello balltrader,

    Thank you for the post.

    It is not supported to change the name of a plot after it is created as there may be unexpected consequences from that, it looks like it does work from my very limited amount of testing. I tried this only in a chart, I am unaware if this fails in other areas that would be up to you to try where you use the script.

    I am using some of the concepts from the following reference sample: https://ninjatrader.com/support/help...r_to_custo.htm

    From what I can tell if you had used a setup like the following where an enum is defined as a public user input you could use the RefreshProperties attribute here to cause a refresh. That being combined with a switch in the set of the property would cause the plots name to be updated when the property changes.

    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class ATest : Indicator
        {
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    AddPlot(Brushes.Red, "APlot");
                    TestEnum = NinjaTrader.NinjaScript.Indicators.ATest.ATestEnum.B;
                }
            }      
    
            public enum ATestEnum { A, B };
    
            private NinjaTrader.NinjaScript.Indicators.ATest.ATestEnum testEnum;
    
            [RefreshProperties(RefreshProperties.All)]
            public NinjaTrader.NinjaScript.Indicators.ATest.ATestEnum TestEnum
            {
                get { return testEnum; }
                set
                {
                    testEnum = value;
                    switch (value)
                    {
                        case ATestEnum.A:
                            Plots[0].Name = "A";
                            break;
                        case ATestEnum.B:
                            Plots[0].Name = "B";
                            break;
                    }
                }
            }
        }
    }
    I look forward to being of further assistance.

    Comment


      #3
      Thank you, I just stumbled across this concept in the COT.cs script and came back here to see if there were any replies.
      I will try your suggestion!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      599 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      344 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      558 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      557 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X