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

Changing a Strategy Label

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

    Changing a Strategy Label

    How can I change a Strategy's Label (the Label Property under "Set Up" in the Dialog) programmatically?

    #2
    Hello NinjaCustomer,

    In the strategy menu, before you have selected the strategy or applied it, it will use the Name property to display in the list. After double-clicking on it or clicking Add to where you configure the strategy the Label field that is shown takes the value of the Name property.

    If you are trying to control specifically this menu and what is shown in the Label, you would need to change the Name. Otherwise, if you are trying to control the label in the chart programmatically you can use the DisplayName override for that. You can also check the State in the override if required, for example, if you only wanted the name to be blank while active or in a certain state you could do that from the override. The sample in the following page is for an indicator, however, this override can be used in a strategy. The sample will help show placement of the override in your script.

    https://ninjatrader.com/support/help...formatting.htm

    Here is a sample of using the State in the override to control naming:

    Code:
     public override string DisplayName
    {
    
            get { if  (State == State.SetDefaults) return Name; else  return "";  }
    
    }

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      what I want to do is control the name of the Strategy as displayed in the Account Data Strategies Tab... anything else is a bonus.

      would the override do it? I can't try it out right now because my strategies are running

      Comment


        #4
        Hello NinjaCustomer,

        That would fall in with Name property, the DisplayName override is used for runtime, the Name property would be used in other cases for the most part. If the label is edited and is not equal to the Name, that is used instead. You would need to specify the Name in State.Defaults for this change to be reported in the AccountData tool.

        In this case, I can't really suggest anything to make a dynamic name for the tool being used, could you better explain the use case? Is this to run different parameters and have that shown as the name or was was the intended reason to change the name dynamically?

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          for simplicity I have 2 sets of Strategies running.. I change the label manually to Buy or Sell... if the Buy property is checked then I want the label to be Buy, if not then Sell.

          Comment


            #6
            Hello NinjaCustomer,

            I wanted to clarify, you are checking a property as true or false along with changing the Label? The label change should be what is needed to show different names in the Account Data tool, if you are setting "buy" and "sell" as the label it should report that way. Are you seeing something else happening?


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Yes I have a boolean Buy property - it means I take only long positions if true, short if false. I couldn't get it exactly perfect but I made it set Name in State.DataLoaded.

              This means that once I enable the strategy then it will change the displayed name in the Strategies tab and if I stop the strategy then it will still retain this new name.

              The main advantage for me to setting this strategy name is that I can see if I accidentally have it checked checked the wrong way (buy instead of sell or vice versa)

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by trilliantrader, 04-18-2024, 08:16 AM
              4 responses
              18 views
              0 likes
              Last Post trilliantrader  
              Started by mgco4you, Today, 09:46 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by wzgy0920, Today, 09:53 PM
              0 responses
              9 views
              0 likes
              Last Post wzgy0920  
              Started by Rapine Heihei, Today, 08:19 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by Rapine Heihei, Today, 08:25 PM
              0 responses
              10 views
              0 likes
              Last Post Rapine Heihei  
              Working...
              X