I have AddDataSeries to the primary series and need to Draw.Text from the secondary data on the primary chart. Howver, when I use the 'CurrentBar' or 0, Draw.Text places the label corresponding to the secondary data location. How do I force or make Draw.Text place the label relative to the primary data?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Draw.Text to place label based on primary data not secondary data position
Collapse
X
-
Draw.Text to place label based on primary data not secondary data position
Hi,
I have AddDataSeries to the primary series and need to Draw.Text from the secondary data on the primary chart. Howver, when I use the 'CurrentBar' or 0, Draw.Text places the label corresponding to the secondary data location. How do I force or make Draw.Text place the label relative to the primary data?Tags: None
-
Hello kashter,
Thanks for your post.
Each data series will have its own CurrentBar. Each data series will call the OnBarUpdate() and will switch references such as Close[0] to point to the data series that called OnBarUpdate(). As forum member muratb35 pointed out Closes[0][0] is the current bar value of the primary (chart) dataseries. Closes[1][0] would be the current bar value of the 1st added data series. In a multi series script you use plurals of the price followed by the barsarrayindex and then the bar index, so for example Highs[2][1] would be the previous bar [1] from the [2]nd added data series
I suspect you want to segment your code so that it only draws when the chart bars call OnBarUpdate(). You can do this by check the value of BarsInProgress. BarsInProgress will be equal to 0 when the chart bars call OnBarUpdate and will be one when the first added data series calls OnBarUpdate().
You can segment like this:
if(BarsInProgress == 0)
{
// do something
}
I highly recommend that you review this section of the help guide to gain a better and complete understanding of Multi time frame/series coding: https://ninjatrader.com/support/help...nstruments.htm
Comment
-
Hi Paul,
Thanks for your informative and I did use the reference you mention to come up with the separate data. Maybe my original post was not clear, I have the data from the first added data series which is prior session high (Highes[1][0]). The issue is how to use Draw.Text to place a label on the primary's CurrentBar position? I tried CurrentBars[1] but the doesn't put the label at the right most candle.
Comment
-
Paul,
I got the right prior session high (checked on print) and level plots on the chart. I want to place a label at the right most candle (CurrentBar). I am using this;
But places the label on the first data series added (at the end of the prior session). I need it on the present session 'CurrentBar'.Code:Draw.Text(this, "H[1]", "H[1]", 0, Highs[1][0], Brushes.Firebrick);
Comment
-
Hello Kashter,
Thanks for your reply.
I meant to write it as if (your existing conditions to draw && BarsInProgress == 0)
Please change, recompile, then make sure you remove the indicator from the chart after compiling and then reapply the indicator to ensure you are working with the recent changes.
If that does not resolve the issue, please post a screenshot of what the chart looks like and the code section that draws the text
Comment
-
Paul,
Here is the snippet
Code:if (BarsInProgress == 1)// && CurrentBars[1] > 0) { ClearOutputWindow(); Print(string.Format("CurrentBar1 {0} \nOpen[1] {1} \nHigh[1] {2} \nLow[1] {3} \nClose[1] {4} ", CurrentBar, Opens[1][0], Highs[1][0], Lows[1][0], Closes[1][0])); // extend the larger time frame for each primary bar so there are consecutive bars set so we can see it on the chart if (!Values[1].IsValidDataPoint(0)) Values[0][0] = Highs[1][0]; Values[1][0] = Lows[1][0]; Values[2][0] = Closes[1][0]; Draw.Text(this, "H[1]", "H[1] " + Highs[1][0].ToString(), 0, Highs[1][0], Brushes.Firebrick); Draw.Text(this, "L[1]", "L[1] " + Lows[1][0].ToString(), 0, Lows[1][0], Brushes.Snow); Draw.Text(this, "C[1]", "C[1] " + Closes[1][0].ToString(), 0, Closes[1][0], Brushes.LimeGreen);
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment