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!
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
NinjaTrader
Add Plot Names to single indicator?
Collapse
X
-
Tags: None
-
yes you could do it by telling a line in that indies code the show names on only the indies w a certain letter, name it 'x' and you can add a secondary repeat of that line that if there is a indie named 'b' then it will display the plot names, you can also say if there is no indie Label to show names of those indies, depends on if you only have one to show names or names of others exceeding one.
I have part of that inside an indie which I want named on plots, so then add a secondary line that says 'x' and 'y' can be named and dipsplay in the margin their labels, which works same as long as those others name been renamed in label then added.
-
You can modify the indicator to only look for specific indicator. You can add a condition that is: if (indicator.Name == (name of your indicator)) then show the plot name (or any name you wish)
Comment
-
I tried numerous possibilities and eventually gave up, but I appreciate the replies.
This is the part I tried changing. This is the original code:
Code:// all of this for adding plot names try { if(indicatorCollection == null) return; TextFormat textFormat = TextFontta.ToDirectWriteTextFormat(); foreach (NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator in indicatorCollection) { if (indicator.Panel == this.Panel || indicator.Panel == 0) // process each indicator in this panel { if (indicator.Name != "AddPlotBPivots") // don't need to label this indicator... { if (indicator.State == State.Realtime) { for (int seriesCount = 0; seriesCount < indicator.Values.Length ; seriesCount++) // process each plot of the indicator { double y = -1; double startX = -1; int lastBarPainted = ChartBars.ToIndex-1; Plot plot = indicator.Plots[seriesCount]; startX = ChartPanel.W - RSmargin +LEoffset; double val = indicator.Values[seriesCount].GetValueAt(lastBarPainted); y = chartScale.GetYByValue(val) - (textFormat.FontSize / 2)-1; // try to center text on plot's last location Point startPoint = new Point(startX, y); TextLayout textLayout = new TextLayout(Globals.DirectWriteFactory, plot.Name, textFormat, textFormat.FontSize+textLength, textFormat.FontSize); RenderTarget.DrawTextLayout(startPoint.ToVector2() , textLayout, plot.BrushDX); textLayout.Dispose(); } } } }
Code:protected override void OnBarUpdate() { indicatorCollection = null; if (ChartControl != null && ChartControl.Indicators != null) lock (ChartControl.Indicators) indicatorCollection = ChartControl.Indicators.ToList(); } public override void OnRenderTargetChanged() { indicatorCollection = null; if (ChartControl != null && ChartControl.Indicators != null) lock (ChartControl.Indicators) indicatorCollection = ChartControl.Indicators.ToList(); }
Comment
-
Hello Bob-Habanai,
You dont need to modify the OnBarUpdate or OnRenderTargetChanged code.
If you are trying to make this work for only a single indicator you would need to check for that indicators name as part of the conditions in the loop.
Code:if (indicator.Name == "MyIndicatorNameHere") // only label the indicator you wanted.
JesseNinjaTrader Customer Service
Comment
-
Hi Jessy,
I tried putting your line here:
Code:foreach (NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator in indicatorCollection) { [B]if (indicator.Name == "PriorDayOHLC") // only label the indicator you wanted.[/B] { if (indicator.Name != "AddPlotBPivots") // don't need to label this indicator...
Comment
-
I tried to bold the line for you to read, but apparently I'm not allowed to bold the important line.
Comment
-
Hello Bob-Habanai,
You dont need to add indicators which you dont want as conditions. Adding only the one indicator that you wanted would prevent other differently named indicators from being used.
Code:foreach (NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator in indicatorCollection) { if (indicator.Name == "PriorDayOHLC") // only label the indicator you wanted.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ETFVoyageur, Today, 07:55 PM
|
0 responses
6 views
0 likes
|
Last Post
by ETFVoyageur
Today, 07:55 PM
|
||
Started by janio973, Today, 07:24 PM
|
1 response
7 views
0 likes
|
Last Post Today, 07:35 PM | ||
Started by aligator, 01-06-2022, 12:14 PM
|
4 responses
242 views
0 likes
|
Last Post
by john_44573
Today, 06:11 PM
|
||
Started by reynoldsn, Today, 05:56 PM
|
0 responses
13 views
0 likes
|
Last Post
by reynoldsn
Today, 05:56 PM
|
||
Started by bortz, 11-06-2023, 08:04 AM
|
51 responses
1,996 views
0 likes
|
Last Post
by aligator
Today, 05:50 PM
|
Comment