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
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
-
Hello Vanderbeke,
Thanks for your reply.
Perhaps I am not understanding but the references I provided are for use in an indicator as these are methods you can use in ninjascript to draw the zones. (They also happen to be available as drawing tools through the charts drawing tool icon).Paul H.NinjaTrader Customer Service
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.Paul H.NinjaTrader Customer Service
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.htmPaul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johnMoss, 03-04-2024, 01:53 PM
|
3 responses
41 views
0 likes
|
Last Post
by AndyM
Today, 06:13 PM
|
||
Started by algospoke, Today, 06:01 PM
|
0 responses
2 views
0 likes
|
Last Post
by algospoke
Today, 06:01 PM
|
||
Started by cre8able, Today, 05:53 PM
|
0 responses
3 views
0 likes
|
Last Post
by cre8able
Today, 05:53 PM
|
||
Started by Wessel, 03-23-2024, 02:37 PM
|
3 responses
23 views
0 likes
|
Last Post Today, 04:58 PM | ||
Started by martini, Yesterday, 04:45 PM
|
4 responses
32 views
0 likes
|
Last Post
by martini
Today, 04:48 PM
|
Comment