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

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.
    JesseNinjaTrader Customer Service

    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 traderqz, Today, 12:06 AM
      10 responses
      17 views
      0 likes
      Last Post traderqz  
      Started by algospoke, 04-17-2024, 06:40 PM
      5 responses
      46 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by arvidvanstaey, Today, 02:19 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by mmckinnm, Today, 01:34 PM
      3 responses
      5 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by f.saeidi, Today, 01:32 PM
      2 responses
      8 views
      0 likes
      Last Post f.saeidi  
      Working...
      X