So, I decided to build something into the indicator to display the current version number and the build date & time, like I do with other applications written in C++ on other platforms.
And I found that C# has no simple equivalent to the C++ built-in constants of "__DATE__" and "__TIME__", which will very simply put string values containing the date & time that the last build was done into the object file generated by the compiler.
But, after much searching (I thought this project was going to take 12 seconds, boy was I wrong), I found the following code that's supposed to display the version number and date and time of a C# Assembly:
System.Reflection.Assembly assem = System.Reflection.Assembly.GetExecutingAssembly(); // Get a pointer to the assembly for the current routine. Version vers = assem.GetName().Version; // Get the version of that assembly. DateTime buildDate = new DateTime(2000, 1, 1).AddDays(vers.Build).AddSeconds(vers.Revision * 2); // Build time is relative to 1/1/2000 Print( "Version=" + vers.ToString() + " DateString=" + buildDate.ToString() ); // Display message in NinjaTrader's Output window.
What I really want is what C++ provides... that the compiler embeds the date & time information into its output file, so that when I run the program, the program can display the time that it was last built.
Is there any way that I can display the time of the last compile of my indicator or strategy?
If not, would you consider adding something like this in the future? (i.e., embedding the compile date & time into each indicator and strategy module and providing a way to reference it at runtime as a Double or String or DateTime)
Comment