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

Override Indicator Label Name

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

    Override Indicator Label Name

    Is there a way to override the label name that is created on the chart?

    It seems to be the base name as determined by the Name property coupled with any parameters marked with a [NinjaScriptProperty] attribute.

    In some cases, if a lot of parameters are specified, this can become a bit obtrusive.

    Is there a way we can hook into where the indicator is rendered or update the format/template to provide a custom name?


    Thanks in advance?

    #2
    public override string DisplayName
    {
    get { return "whatever you like goes here"; }
    }

    Comment


      #3
      If you don't want to code the DisplayName method, you can simply enclose whatever text you'd like in quotation marks in the Indicators Properties dialog in the Set up group's Label item:
      Set up
      Label "MyShortName"

      Comment


        #4
        Duh!

        Both of those were much*simpler than I was making it.

        Thanks!!!

        Comment


          #5
          Thanks for the replies so far, this has been very helpful.

          I have a similar question, I would like to modify the text and add the current ATR. I have written:

          public override string DisplayName
          {
          get {return Name, +" " ATR(14)[0];}
          }

          I get the following error: An object reference is required for the non-static field, method, or property 'NinjaTrader.NinjaScript.Indicators.Indicator.ATR( int)'

          Can anyone provide guidance on what code to add to the lines above to be able to plot the current ATR next to the display name?

          Many thanks in advance for your consideration.

          Comment


            #6
            Hello ashlantz,

            Thank you for your post and welcome to the NinjaTrader Support Forum!

            Pass the ATR value to a double, then call that double in DisplayName. For example:
            Code:
            	public class MyCustomIndicator1 : Indicator
            	{
            		[B]private double atrValue = 0;[/B]
            		protected override void OnStateChange()
            		{
            			if (State == State.SetDefaults)
            			{
            				Description									= @"Enter the description for your new custom Indicator here.";
            				Name										= "MyCustomIndicator1";
            				Calculate									= Calculate.OnBarClose;
            				IsOverlay									= true;
            				DisplayInDataBox							= true;
            				DrawOnPricePanel							= true;
            				DrawHorizontalGridLines						= true;
            				DrawVerticalGridLines						= true;
            				PaintPriceMarkers							= true;
            				ScaleJustification							= NinjaTrader.Gui.Chart.ScaleJustification.Right;
            				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
            				//See Help Guide for additional information.
            				IsSuspendedWhileInactive					= true;
            			}
            			else if (State == State.Configure)
            			{
            			}
            		}
            
            		protected override void OnBarUpdate()
            		{
            			[B]if (CurrentBar <= 14) return;
            			
            			atrValue = ATR(14)[0];[/B]
            		}
            		
            [B]		public override string DisplayName
            		{
            			get { return atrValue.ToString(); }
            		}[/B]
            	}
            Please let me know if you have any questions.

            Comment


              #7
              Thank you Patrick, exactly what I've been trying to figure out, I cannot thank you enough for the prompt and very helpful reply.
              -Ashley

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NRITV, Today, 01:15 PM
              2 responses
              9 views
              0 likes
              Last Post NRITV
              by NRITV
               
              Started by frankthearm, Today, 09:08 AM
              7 responses
              31 views
              0 likes
              Last Post frankthearm  
              Started by maybeimnotrader, Yesterday, 05:46 PM
              5 responses
              26 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by quantismo, Yesterday, 05:13 PM
              2 responses
              20 views
              0 likes
              Last Post quantismo  
              Started by adeelshahzad, Today, 03:54 AM
              5 responses
              33 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X