Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can I change the title of the strategy window within the strategy code?

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

    Can I change the title of the strategy window within the strategy code?

    Right now each chart has the title: Instrument Period Date.

    Is it possible to access that property from within the strategy code and change it? let's say adding the account name of running strategy?

    Thanks.

    Edit: I don't mind using reflection if that's the only way.
    Last edited by benharper; 05-14-2015, 11:20 AM.

    #2
    Hello benharper,

    Thank you for your post.

    I am not certain how to remove the date, but using unsupported code in OnStartUp() we can change the label of the chart. Add the following after the Initialize() method and this will change the label to the account name used for the strategy (this code will only work in a strategy due to calling Account.Name):
    Code:
    		protected override void OnStartUp()
    		{
    			ChartControl.BarsArray[0].BarsData.Label = @"""" + Account.Name + @"""";
    		}

    Comment


      #3
      Excellent! Exactly what I was looking for. And I don't mind the date really, I just want to add the strategy name and the account. So this is perfect.

      Code:
      string label = Instrument.FullName + " " + Bars.Period.Value + ""+ Bars.Period.Id.ToString().Substring(0,1) + " " + this.Name + " " + Account.Name;
                  ChartControl.BarsArray[0].BarsData.Label = @"""" + label + @"""";

      Comment


        #4
        One more clarification: shouldn't I call Base.OnStartUp()? Can I assume the base function is empty?

        Comment


          #5
          Hello benharper,

          You can call
          protected override void OnStartUp()
          in the Strategy class. No need to call Strategy or Indicator Base.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          65 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X