Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I want to blank out indicator labels so they don't display on the chart, but I still want a name to show up in the list of Configured indicators I have applied to my chart. Normally a name is retained, but on some of the custom indicators I have, blanking out the label blanks out the name.
What governs this in the code, and exactly what would I add/change to fix this?
Vicki
Can you help answer these questions from other members on NexusFi?
Not sure if this is what you mean... but in the Indicator / Label window if you put quotation marks around your preferred label name that's what will show up on the chart
In the code above, when you open up the list of indicators, you'll see "My Cool Indicator" in the list (this comes from the value of Name in State.SetDefaults).
When you click the "i" at the top next to Available, you'll see what's in the Description field.
Setting this.Name to null in State.Configure will prevent the name from showing up at the top left corner of the chart.
After you've added the indicator, next time you go back to the indicators list, you'll see My_Cool_Indicator (from the "class" line) in the list of configured indicators.
I believe this is what you're looking for. I use this all the time to get rid of the ugly long label on the chart.
As an example I've created (attached) a copy of the NT8 EMA indicator adding the code to display, or not, the indicator name while still having the name listed in your configured list.
I've attached it as "EMA No Label NT8.zip" so you can view the code for yourself.
In OnStateChange I added:-
Note: I set this to "false" so saves unticking the box..(see below)
Just above OnBarUpdate I added:-
In Properties I added:-
Note: you can chose the GroupName for where in the indicator dialog the tick box will appear. ie "Setup" and you can type in your own Display Name ie: "Show Indicator Name"
The whole code:
You'll then get a box you can tick to display or untick to not display the indicator name on the chart:
Thanks! I added "this.Name = "";" to the State.Configure section and compiled. But now when I type the indicator name back into the label, it is automatically getting blanked out, so again, I still don't have it showing in my list of configured indicators. Not sure what I did wrong...
Thanks! I will try this if I have to, but what I don't get is why some indicators automatically still display the indicator name in the Configured list when the label is blanked out, while others don't. I've tried to compare code for indicators that behave differently and I can't find the difference.
zt379
If this helps.
You can apply this to each of your indicators.
As an example I've created (attached) a copy of the NT8 EMA indicator adding the code to display, or not, the indicator name while still having the name listed in your configured list.
I've attached it as "EMA No Label NT8.zip" so you can view the code for yourself.
In OnStateChange I added:-
DisplayIndicatorName = false;
Note: I set this to "false" so saves unticking the box..(see below)
Just above OnBarUpdate I added:-
public override string DisplayName
{
get { if (State == State.SetDefaults)
return Name;
else if (DisplayIndicatorName)
return Name;
else return ""; }
}
In Properties I added:-
[NinjaScriptProperty]
[Display(Name="Show Indicator Name", Description="Draw a symbol to mark change in direction", Order=1, GroupName="Setup")]
public bool DisplayIndicatorName
{ get; set; }
Note: you can chose the GroupName for where in the indicator dialog the tick box will appear. ie "Setup" and you can type in your own Display Name ie: "Show Indicator Name"
The whole code:
public class EMANoLabel : Indicator
{
private double constant1;
private double constant2;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionEMA;
Name = "EMANoLabel";
IsOverlay = true;
IsSuspendedWhileInactive = true;
Period = 14;
///added Display name
DisplayIndicatorName = false;
AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNa meEMA);
}
else if (State == State.Configure)
{
constant1 = 2.0 / (1 + Period);
constant2 = 1 - (2.0 / (1 + Period));
}
}
///added Display Name
public override string DisplayName
{
get { if (State == State.SetDefaults)
return Name;
else if (DisplayIndicatorName)
return Name;
else return "";
}
}
protected override void OnBarUpdate()
{
Value[0] = (CurrentBar == 0 ? Input[0] : Input[0] * constant1 + constant2 * Value[1]);
}
#region Properties
[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)]
public int Period
{ get; set; }
///Display Indicator Name
[NinjaScriptProperty]
[Display(Name="Show Indicator Name", Description="Draw a symbol to mark change in direction", Order=1, GroupName="Setup")]
public bool DisplayIndicatorName
{ get; set; }
#endregion
}
You'll then get a box you can tick to display or untick to not display the indicator name on the chart:
Thanks! I added "this.Name = "";" to the State.Configure section and compiled. But now when I type the indicator name back into the label, it is automatically getting blanked out, so again, I still don't have it showing in my list of configured indicators. Not sure what I did wrong...
Hi,
Setting this.Name to null string in State.Configure will disable the indicator label on the chart. So regardless of what you type in the Label field in Indicator Properties -> Setup -> Label, you will not get any label on the chart in the top left corner. If you want the ability to set a label on the chart, then you shouldn't null the value of this.Name in your script. But that will have the effect of placing the long label on the chart, which I thought you wanted to avoid.
I guess your use of "configured indicators" is confusing me. When you mention "configured indicators", I'm thinking about the list of indicators that show up in the bottom left panel of Indicator properties dialog. You should still get the indicator name showing up there even if you set this.Name to null string. That name comes from the class definition.
You might want to post this question to Ninja scripting support team. They are extremely knowledgeable and on top of everything. If there is a solution, you have a much better chance of getting your response.
Setting this.Name to null string in State.Configure will disable the indicator label on the chart. So regardless of what you type in the Label field in Indicator Properties -> Setup -> Label, you will not get any label on the chart in the top left corner. If you want the ability to set a label on the chart, then you shouldn't null the value of this.Name in your script. But that will have the effect of placing the long label on the chart, which I thought you wanted to avoid.
I guess your use of "configured indicators" is confusing me. When you mention "configured indicators", I'm thinking about the list of indicators that show up in the bottom left panel of Indicator properties dialog. You should still get the indicator name showing up there even if you set this.Name to null string. That name comes from the class definition.
You might want to post this question to Ninja scripting support team. They are extremely knowledgeable and on top of everything. If there is a solution, you have a much better chance of getting your response.
See the attached screen pic. When I blank out the label name in Properties (arrow on the right), the indicator name in the list of Configured indicators (arrow on the left) becomes blanked out. This happens when I set this.Name to null string the same as if I blank out the name in Properties manually. I want to blank it out in Properties (so it doesn't appear on the chart) without losing the indicator name in the list of Configured indicators. The perplexing thing is that for some indicators the indicator name doesn't get blanked out, and for some it does, and I can't see where this is controlled in the code.
I reached out to NinjaScripting support already (right before the weekend), but haven't yet heard back.
See the attached screen pic. When I blank out the label name in Properties (arrow on the right), the indicator name in the list of Configured indicators (arrow on the left) becomes blanked out. This happens when I set this.Name to null string the same as if I blank out the name in Properties manually. I want to blank it out in Properties (so it doesn't appear on the chart) without losing the indicator name in the list of Configured indicators. The perplexing thing is that for some indicators the indicator name doesn't get blanked out, and for some it does, and I can't see where this is controlled in the code.
I reached out to NinjaScripting support already (right before the weekend), but haven't yet heard back.
Thanks!
Thank you for posting the screenshot. Yes, this is what I was referring to also.
It is odd that the name doesn't show up in that list. This has never happened to me and I set this.Name to null string all the time.
Do you have the Name attribute defined and set to some value (not null) in State.SetDefaults?
That's the only thing I can think off. If that doesn't work, I'm afraid I'm out of ideas to try.
I'd be very interested in hearing what Ninja support says. I'd appreciate it if you can share your findings here.
See the attached screen pic. When I blank out the label name in Properties (arrow on the right), the indicator name in the list of Configured indicators (arrow on the left) becomes blanked out.
Instead of completely removing the Label text and leaving it blank..
Try placing/using double quotes ( "" ) for the Label text instead...