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:	2775
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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      598 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      343 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      557 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      555 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X