Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Properties

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

    Custom Properties

    Hi


    I'm often building indicators and strategies for people and to help with possible troubleshooting I typically print out the custom properties and some basic chart settings during State.DataLoaded so I have data to replicate their setup.

    Possibly more of a C# question, but I was wondering if these properties are held somewhere that I can reference rather than manually typing in the code each time to print them out. I'm interested in the property name and the value that has been entered by the user.

    Do you know if that exists or any other tips to help make it more efficient?

    Thanks
    Tim
    Click image for larger version

Name:	customProperties.png
Views:	2783
Size:	253.5 KB
ID:	1225805

    #2
    Hello Tim,

    There would not be anything supported to automatically print out all properties in a script.

    This may be possible using Reflection, however note, as using Reflection is not supported the NinjaScript Engineering team would not be able to assist with this.

    This thread will remain open for any community members that would like to provide unsupported code.

    Below is a link to a google search for similar posts.


    As well as another direct forum thread where this is discussed.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea

      I did some more research online and think I've found a working solution:

      Code:
      using System.Reflection;
      Code:
      else if (State == State.DataLoaded)
                  {
                      StrategyTemplate s1 = new StrategyTemplate();
                      foreach (var prop in s1.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance))
                      {
                          Print(string.Format("{0}={1}", prop.Name, prop.GetValue(s1, null)));
                      }​
      }
      Replace StrategyTemplate with whatever your class (strategy or indicator) is called.

      Hopefully, this is useful to someone else..!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      93 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      138 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      123 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      73 views
      0 likes
      Last Post PaulMohn  
      Working...
      X