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

Expand/collapse properties

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

    Expand/collapse properties

    Hello,

    I'm looking to make a set of properties be hidden/shown using the [+] button mechanics that the default Plot pen properties use for setting the properties of a plot.

    I've been attempting to use ExpandableObjectConverter. Hiding/showing the properties/values is working fine. My problem is that the default values of the intval and boolval properties are used when clicking 'Apply' after changing the values in the property grid dialog. I'm trying to make the user-defined values persist after the indicator is applied.

    Here's what I have so far:

    TestClass testobj = new TestClass();

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class TestClass
    {
    private int intval = 4;
    private bool boolval = false;

    public int MyInt
    {
    get { return intval; }
    set { intval = value; }
    }

    public bool MyBool
    {
    get { return boolval; }
    set { boolval = value; }
    }

    public override string ToString() { return "test str"; }
    }

    [Description("Test property")]
    [Category("Test Category")]
    [Gui.Design.DisplayName("Testing")]
    public TestClass TestProp
    {
    get { return testobj; }
    }


    Thanks for your help!

    #2
    Hello deltaZ,

    Thank you for reporting the behavior.

    I was able to reproduce and I am inquiring about the cause and expected behavior.

    Please note that type converters are not documented or officially supported.

    I appreciate your patience.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello deltaZ,

      I got it worked out, the expandable class is setting internal private variables. These are not being accessed outside of the class.

      I was working with brushes and was already working on this question, and the solution I worked out is in an example with brushes. But this still relates to any object type.

      Also, this example was attempting to demonstrate a few different ways of creating properties and is not directly related to your inquiry, but does have a demonstration of how this would work correctly for your question.
      Attached Files
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thanks for looking into this for me ChelseaB.

        Unfortunately I still run into the same issue when declaring the expandable class variables as public -- the user-defined values do not persist.


        Code:

        TestClass testobj = new TestClass();

        [TypeConverter(typeof(ExpandableObjectConverter))]
        public class TestClass
        {
        public int intval = 4;
        public bool boolval = false;

        public int MyInt
        {
        get { return intval; }
        set { intval = value; }
        }

        public bool MyBool
        {
        get { return boolval; }
        set { boolval = value; }
        }

        public override string ToString() { return "test str"; }
        }


        [Description("Test property")]
        [Category("Test Category")]
        [Gui.Design.DisplayName("Testing")]
        public TestClass AThing
        {
        get { return testobj; }
        }


        Were you able to get it working after reproducing from my original post?

        Comment


          #5
          Hello deltaZ,

          Where are you trying to use this value in the code?

          Are you using the class object and accessing the child property (i.e. AThing.intval)?

          Also, is the AThing meant to be a NinjaScriptProperty?

          Wait, it looks like you have a get and no set. So the property can be gotten but can't be set.

          Have you tried using the example I have provided you?
          Last edited by NinjaTrader_ChelseaB; 05-22-2017, 03:47 PM.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hello deltaZ,

            This was completely my mistake.

            I overlooked you were asking this for NinjaTrader 7 and not for NinjaTrader 8.

            I was focusing on NinjaTrader 8 and was not testing this with NinjaTrader 7.

            For NinjaTrader 7, this would be outside of what we are able to able to support. However, Bertrand has posted some links you may find helpful.


            Another trader has offered to share his unsupported code.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks for the resources. I'll see if I can find a solution there.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Working...
              X