Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PropertyDescriptor GetValue and SetValue

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

    PropertyDescriptor GetValue and SetValue

    From within an indicator, how can a BarsType property be accessed or modified?
    For the excerpt below what is the correct code for the "component" parameter?

    PropertyDescriptor pd = Bars.BarsType.Properties["BarsPeriodType"];
    pd.SetValue(component, "somevalue");
    string result = pd.GetValue(component);



    #2
    Hello fjwltn,

    What property are you trying to read? In general an indicator wont be able to modify any property on a BarsType, the BarsType is configured by the chart. You can read bars type properties, the easiest way is to use the Bars object.

    Comment


      #3
      The code is representative.
      I am utilizing the custom properties, so for discussion we'll use "Value2"

      PropertyDescriptor pd = Bars.BarsType.Properties["Value2"];

      In my custom BarsType class I successfully renamed it to "MyProperyName" and it is working as expected in the BarsType Properties dialog window.
      After renaming, the original property name must still be used to access it in the collection.
      That all works, and I get a properly populated PropertyDescriptor object with this code:
      PropertyDescriptor pd = Bars.BarsType.Properties["Value2"];

      However, nothing I have tried so far (this, Bars.BarsType, etc) works with GetValue or SetValue, with all attempts yielding the error "Object does not match target type"

      - Fred


      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      220 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      135 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      150 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      235 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      193 views
      0 likes
      Last Post CarlTrading  
      Working...
      X