Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic Properties

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

    Dynamic Properties

    I want to modify the properties for a strategy at runtime.

    Currently we create properties at compile time like:

    [Description("Trade second contract")]
    [GridCategory("Parameters")]
    public bool TradeSecondContract
    {
    get { return useContract2; }
    set { useContract2 = value; }
    }

    I would like to be able to modify which parameters are shown, depending on options the user selects. For instance, if they choose to trade 2 contracts instead of 1, I show exit options for the second contract.

    I did find where the base strategy has a ParameterCollection that can be accessed through this.Parameters. It contains each of my parameters and their types... but not the description and grid category.

    I have tried modifying this list and it does not affect the GridControl. I am guessing NinjaTrader is either using a GridControl or a custom grid type (NTGrid2?).

    I'm sure there must be some way to get a reference to the GridControl, but I have yet to find it. I am also guessing your answer is going to be that this is not supported.

    I'm fine with an unsupported answer... can someone just nudge me in the right direction?

    If you need more of a description about my setup and why I need this I would be happy to respond with such.

    Thanks

    #2
    Hello d1g1talfr3ak,
    Welcome to the forum and I am happy to assist you.

    It is possible to change the properties during run time but it beyond what we could support. I leave the thread open for any community member to answer your query.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      ChartControl or Parent Form or ???

      Anyone...?

      Can anyone at least tell me if I'm looking in the right direction? Right now I'm looking at

      this.ChartControl in the base strategy.

      Maybe using this.ChartControl.Controls to try and get access to GridControl?

      Or

      Form parent = this.ChartControl.FindForm();
      Then I can get the Handle to the form and search for the GridControl?

      I am worried though that the ChartControl.FindForm() will return the form with the actual bar chart that the strategy is added too, and I do not see the properties from there. When you bring up the Strategies window (such as by clicking the $ icon on the chart panel), it has a list of all the strategies and properties of selected one on the right.

      I hooked into the Initialize() function of my base strategy and can see that the Initialize is being called for each strategy everytime you click on it in that dialog. Also, this.ChartControl is null before the strategy is selected and the "New" button is clicked.

      I have also tried using the .NET Reflector to look inside the NinjaTrader.Core dll a little and I do not see any direct way to reference the properties grid control from in StrategyBase. There is a class, however, called NewStrategy that extends UserControl that has a PropertyGrid.

      It would really help and save a lot of time reversing NinjaTrader if someone could clue me in to how to do this.

      Joydeep, if you wanted to tell me off-the-record at my forum name at gmail.com, I promise not to tell anyone you helped. (BTW, my forum name is d1g1talfr3ak)

      Comment


        #4
        Hello d1g1talfr3ak,
        You can add some custom button and change your property by clicking them. This should get you started http://www.ninjatrader.com/support/f...24&postcount=1

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          For anyone else that is looking for the solution to Dynamic Properties you may find it here:

          Big Mike Trading

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          646 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          367 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          570 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X