Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Plotting vertical zones
Collapse
X
-
Plotting vertical zones
Hi guys, I was wondering what the best approach would be to plot vertical fixed zones? For example from 0 to 1 in green, from 1 to 2 blue, ... At the moment I'm doing this by plotting bars with the width set to a value big enough so they overlap. This is working fine but I'm not sure if this is the right or the best approach to do this.Tags: None
-
-
Hi Paul, I was a bit too fast with my answer. Your solution is perfect for drawing zones on the chart. But my intention is to draw these zones inside my indicator which is located under the chart. Is there any similar solution for this?
Comment
-
Hi Paul
Below is an excerpt of the code mentioned on the info page. For the coördinates, information of the bars is used. But my inidicator has values from 0 to 5 because it has its own window with a separate scale. Could you give me an example how this will work? Perhaps using the MACD indicator as an example. Everything above null in green, and everthing beneath in red?
Draw.RegionHighlightY(this, "tag1", High[0], Low[0], Brushes.Blue, Brushes.Green, 20);
Comment
-
Hello Vanderbeke,
Thanks for your reply.
The example in the helpguide is incorrect, it is missing a parameter. We will update the helpguide example shortly.
In the case of your indicator, you could do something like this:
if (CurrentBar == 0)
{
Draw.RegionHighlightY(this, "test", true, 0, 5, Brushes.LightBlue, Brushes.Blue, 20);
Draw.RegionHighlightY(this, "test1", true, 0, -5, Brushes.LightPink, Brushes.Pink, 20);
}
On the first bar loaded it draws the zones once.
Comment
-
Hi Paul
I must be doing something wrong because when I add your code to the indicator it is showing zones on the chart and not on the indicator. Below an example of the MACD indicator where I added your code.
Code:protected override void OnBarUpdate() { double input0 = Input[0]; if (CurrentBar == 0) { fastEma[0] = input0; slowEma[0] = input0; Value[0] = 0; Avg[0] = 0; Diff[0] = 0; } else { double fastEma0 = constant1 * input0 + constant2 * fastEma[1]; double slowEma0 = constant3 * input0 + constant4 * slowEma[1]; double macd = fastEma0 - slowEma0; double macdAvg = constant5 * macd + constant6 * Avg[1]; fastEma[0] = fastEma0; slowEma[0] = slowEma0; Value[0] = macd; Avg[0] = macdAvg; Diff[0] = macd - macdAvg; } if (CurrentBar == 0) { Draw.RegionHighlightY(this, "test", true, 0, 5, Brushes.LightBlue, Brushes.Blue, 20); Draw.RegionHighlightY(this, "test1", true, 0, -5, Brushes.LightPink, Brushes.Pink, 20); } }
Comment
-
Hello Vanderbeke,
Thanks for your reply.
Unless otherwise specified, draw objects will be drawn on the price panel.
To change that behavior, in the OnStateChange() method, within State.SetDefaults, please add the statement: DrawOnPricePanel = false; // draw objects in the indicator's panel
Reference: https://ninjatrader.com/support/help...pricepanel.htm
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
656 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
371 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 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
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
579 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment