Do you think it is possible to save Zorder settings with chart templates as well? Finally it is a property of the chart and not of the workspace?
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
zOrder, Putting Indicators behind Price.
Collapse
X
-
Have seen system indicators that set ZOrder to -1; so there is a range of values that ZOrder can take. Can I set it to -2?
Do you think it is possible to save Zorder settings with chart templates as well? Finally it is a property of the chart and not of the workspace?
-
Thanks a lot guys, for the ZOrder hint. I wished since a long time that NT implements the possibility to paint graphics behind the chart-bars programmatically. But it is there already, not documented, but used by some of the system indicators.
Regards
Ralph
Comment
-
DrawArrowDown behind plot
Guys, is there a way to draw an arrow behind a plot within the same indicator?
As far as I can tell the arrow is always on top, regardless of the order in which the arrow and plot are drawn, and regardless of applying the "SeparateZOrder=true" command to the arrow.
Thanks for the help,
Light
Comment
-
Light, works for me here for the IDrawObjects the arrows offer as well - setting SeparateZOrder to true just offers defining the ZOrder for the draw object to be separate, you would then to change it via Shift and the mousewheel as those objects are drawn on the chart by the indicator.BertrandNinjaTrader Customer Service
Comment
-
Not yet working for me...
Thanks Bertrand. I hope you're doing well.
I am trying to get an arrow and a plotted line to both be over the chart bars, with the arrow behind the line (within the same indicator). I am using (essenially) the following code in attempt to accomplish this:
Code:private IDrawObject Arrow; //Plot some line, then under some condition do... Arrow=DrawArrowUp("Arw"+(CurrentBar-1).ToString(),true,1,Value[1],Color.Lime); Arrow.SeparateZOrder=true;
Is there a way to get the arrows behind the line with the line and arrows above the bars? (Actually, I haven't been able to get the arrow behind the line at all -- even if both are behind the bars.)
Thanks again for your help.
Light
Comment
-
Slightly modified WMA code...
Thanks Bertrand. This is the code I used to produce the image in my previous post. It modifies NT's WMA only by adding lines 19 and 47-51 to plot Arrows at changes in slope. (I also added a shiftArrow variable to manually draw the arrows in the same region as the WMA for demonstration, but it has no other role.) Here is the full code:
Code:#region Using declarations using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel; using System.Xml.Serialization; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion namespace NinjaTrader.Indicator { public class WMAwithArrows : NinjaTrader.Indicator.Indicator { #region Variables //Relevant part next line: private IDrawObject Arrow; private int period = 14; private double arrowShift = 0.5; #endregion protected override void Initialize() { Add(new Plot(Color.Orange, Name)); Overlay = true; } protected override void OnBarUpdate() { if (CurrentBar == 0) Value.Set(Input[0]); else { int back = Math.Min(Period - 1, CurrentBar); double val = 0; int weight = 0; for (int idx = back; idx >=0; idx--) { val += (idx + 1) * Input[back - idx]; weight += (idx + 1); } Value.Set(val / weight); //Relevant part in next few lines: if (CurrentBar>5) { if (Value[1]<Value[2] && Value[1]<Value[0]) {Arrow=DrawArrowUp("Arw"+(CurrentBar-1).ToString(),true,1,Value[1]+ArrowShift*TickSize,Color.Lime); Arrow.SeparateZOrder=true;} else if (Value[1]>Value[2] && Value[1]>Value[0]) {Arrow=DrawArrowDown("Arw"+(CurrentBar-1).ToString(),true,1,Value[1]-ArrowShift*TickSize,Color.Red); Arrow.SeparateZOrder=true;} } } } #region Properties [Description("Numbers of bars used for calculations")] [GridCategory("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } [Description("Arrow Shift")] [GridCategory("Parameters")] public double ArrowShift { get { return arrowShift; } set { arrowShift = value; } } #endregion } }
Thanks again for the help.
Best wishes,
Light
Comment
-
Thanks Bertrand. I tried that earlier by removing one of the arrows entirely, but had the same result. I have since tried it again, this time by inserting "UArrow" and "DArrow" as separate IDrawObject variables, with corresponding changes to the DrawArrowUP and DrawArrowDown section. But I still have only two levels of ZOrder, with no independent control of the arrows compared to the WMA line. Full code here:
Code:#region Using declarations using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel; using System.Xml.Serialization; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion namespace NinjaTrader.Indicator { public class WMAwithArrows : NinjaTrader.Indicator.Indicator { #region Variables private IDrawObject DArrow; private IDrawObject UArrow; private int period = 14; private double arrowShift = 0.5; #endregion protected override void Initialize() { Add(new Plot(Color.Orange, Name)); Overlay = true; } protected override void OnBarUpdate() { if (CurrentBar == 0) Value.Set(Input[0]); else { int back = Math.Min(Period - 1, CurrentBar); double val = 0; int weight = 0; for (int idx = back; idx >=0; idx--) { val += (idx + 1) * Input[back - idx]; weight += (idx + 1); } Value.Set(val / weight); if (CurrentBar>5) { if (Value[1]<Value[2] && Value[1]<Value[0]) {UArrow=DrawArrowUp("UArw"+(CurrentBar-1).ToString(),true,1,Value[1]+ArrowShift*TickSize,Color.Lime); UArrow.SeparateZOrder=true;} else if (Value[1]>Value[2] && Value[1]>Value[0]) {DArrow=DrawArrowDown("DArw"+(CurrentBar-1).ToString(),true,1,Value[1]-ArrowShift*TickSize,Color.Red); DArrow.SeparateZOrder=true;} } } } #region Properties [Description("Numbers of bars used for calculations")] [GridCategory("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } [Description("Arrow Shift")] [GridCategory("Parameters")] public double ArrowShift { get { return arrowShift; } set { arrowShift = value; } } #endregion } }
Are you able to produce a Plot line (e.g. a moving average) with arrows that appear beneath the line (assuming corresponding choice of ZOrder) within one indicator? If so, could you post your code?
Thanks again for your help.
Light
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by helpwanted, Today, 03:06 AM
|
1 response
10 views
0 likes
|
Last Post Today, 03:35 AM | ||
Started by Brevo, Today, 01:45 AM
|
0 responses
9 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
242 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
386 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
Comment