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

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:	2728
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 mattbsea, Today, 05:44 PM
      0 responses
      4 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      31 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,282 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      20 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Working...
      X