Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is it safe to modify a Strategy's this.Name during State.Configure/State.DataLoaded?

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

    Is it safe to modify a Strategy's this.Name during State.Configure/State.DataLoaded?

    Hello

    I am running NT 8.0.18.0 64-bit

    During State.Configure or State.DataLoaded, I would like to programmatically change the Strategy's this.Name to reflect how the Strategy has been configured. This provides a much more informative name and better sorting mechanism on the Control Center tabs.

    This appears to work for normal operation of a Strategy, but fails when backtesting (the dreaded "Object reference not set..." message appears when running the backtest).
    I could avoid the problem by disabling this code when backtesting.

    Other than the problem with backtesting, is it safe to modify this.Name during State.Configure or State.DataLoaded?

    Thank you

    #2
    Hello Zigfried,

    What specifically are you using in the name when you get the Object reference not set.error? That indicates something you are using is null.

    Not all tools are identical so you may see errors if you for example use a property of the chart which is not present in a backtest. Just checking for null and giving a different string should be sufficient if you are using something that is null in a backtest:

    Code:
    string myString = ChartControl != null ? "UseAPropertyFromTheChart" : "MyStringWhenNotNull";
    To answer the question you can change the name in any state and actually there is an override for that purpose as well: https://ninjatrader.com/support/help...ub=displayname

    The DisplayName override property can be used for custom naming, you can also use the State object there.

    I look forward to being of further assistance.

    Comment


      #3
      Hello Jesse

      There are no nulls in the programmatically determined name, but there is a period(.).

      A typical name that I want to use would be as follows:
      PCM1-00-P-Trade-AX-ABCD-30-0.6

      I tried the DisplayName override, but that doesn't seem to change anything in the Control Center tabs. It changes the Strategy stuff at the top-right corner of the chart.

      In the Control Center, I know that the Parameters column gives most of the information that I want, but it is way too verbose in my applications, so the information I am interested in is hard to easily find.

      In summary, I am trying to use a column in the Control Center to concisely show specific info about the strategy configuration. I was trying to use Strategy Name column, which appears on the Strategies tab. That way I could quickly scan all my running Strategies in the Control Center, and more easily know exactly what they all do.

      Thank you

      Comment


        #4
        Hello Zigfried,

        Thank you for the reply.

        Yes the name should be able to be set in any state, you would need to check the other values you are using to see what is null in that use case. The error you reported specifically means something is null which was used.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Jesse

          I am using the following info to derive the Name: EDIT-Does Account.Connection.Options.Name exist for Backtest?

          1) Account.Connection.Options.Name
          2) Strategy Properties, all of which have an Enum associated with them, so they can't be null (and I am not testing this by Optimizing, where a null could possibly be entered for a Property).

          Note that I am performing ToString and Replace operations to grab the info and format it more clearly, and I am always getting the proper name, and I am not replacing anything with null.
          When I comment out the code that changes the Name, Backtest works fine.

          But I think you answered my question by saying that the name can be changed in those states. So I will just defeat the name change when Backtesting. The Strategy Name appears as part of my Order Names, so I can still track down what I need in the Bactest/Optimize results.

          Thanks again
          Last edited by Zigfried; 11-15-2019, 05:06 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          62 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          134 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X