Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
N7 DrawLine not working
Updated February 2, 2014
trending_up
1,748 views
thumb_up
9 thanks given
group
1 followers
forum
4 posts
attach_file
0 attachments
N7 DrawLine not working
February 1st, 2014, 11:29 AM
Roseville CA
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21
Hello,
Any ideas on why this is drawing on chart?
Code
protected override void OnBarUpdate()
{
DrawLine("MyLine", 10, Close[10], 0, Close[0], Color.Blue);
}
thank you
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
February 1st, 2014, 11:39 AM
Columbus, OH
Market Wizard
Experience: None
Platform: NT 8, TOS
Trading: ES
Posts: 3,603 since Aug 2009
Thanks Given: 5,139
Thanks Received: 11,527
ceramictilepro
Hello,
Any ideas on why this is drawing on chart?
Code
protected override void OnBarUpdate()
{
DrawLine("MyLine", 10, Close[10], 0, Close[0], Color.Blue);
}
thank you
I think if you add: "if (CurrentBar < 10) return;"
it should work
edit:
made a simple example where you can change the lookback period in the indicator window:
Code
#region Variables
private int length = 10;
private Color lineColor = Color.Blue;
private DashStyle dash0Style = DashStyle.Solid;
private int plot0Width = 1;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < length)
return;
DrawLine("MyLine", true, length, Close[length], 0, Close[0], lineColor, dash0Style, plot0Width);
}
#region Properties
[Description("lookback period")]
[Category("Line Settings")]
[Gui.Design.DisplayNameAttribute("Length")]
public int Length
{
get { return length; }
set { length = Math.Max(1, value); }
}
/// <summary>
/// </summary>
[XmlIgnore()]
[Description("line color")]
[Category("Line Settings")]
[Gui.Design.DisplayName("Line Color")]
public Color LineColor
{
get { return lineColor; }
set { lineColor = value; }
}
[Browsable(false)]
public string LineColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(lineColor); }
set { lineColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
}
/// <summary>
/// </summary>
[Description("DashStyle for Line")]
[Category("Line Settings")]
[Gui.Design.DisplayNameAttribute("Line Dash Style")]
public DashStyle Dash0Style
{
get { return dash0Style; }
set { dash0Style = value; }
}
/// <summary>
/// </summary>
[Description("Width for Line")]
[Category("Line Settings")]
[Gui.Design.DisplayNameAttribute("Line Width")]
public int Plot0Width
{
get { return plot0Width; }
set { plot0Width = Math.Max(1, value); }
}
#endregion
February 2nd, 2014, 12:22 PM
Roseville CA
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21
Very Nice! I'm using this one for sure!
Can you tell me if this can be attached to global drawing objects?
Thank You!
Silvester17
I think if you add: "if (CurrentBar < 10) return;"
it should work
edit:
made a simple example where you can change the lookback period in the indicator window:
Code
#region Variables
private int length = 10;
private Color lineColor = Color.Blue;
private DashStyle dash0Style = DashStyle.Solid;
private int plot0Width = 1;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < length)
return;
DrawLine("MyLine", true, length, Close[length], 0, Close[0], lineColor, dash0Style, plot0Width);
}
#region Properties
[Description("lookback period")]
[Category("Line Settings")]
[Gui.Design.DisplayNameAttribute("Length")]
public int Length
{
get { return length; }
set { length = Math.Max(1, value); }
}
/// <summary>
/// </summary>
[XmlIgnore()]
[Description("line color")]
[Category("Line Settings")]
[Gui.Design.DisplayName("Line Color")]
public Color LineColor
{
get { return lineColor; }
set { lineColor = value; }
}
[Browsable(false)]
public string LineColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(lineColor); }
set { lineColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
}
/// <summary>
/// </summary>
[Description("DashStyle for Line")]
[Category("Line Settings")]
[Gui.Design.DisplayNameAttribute("Line Dash Style")]
public DashStyle Dash0Style
{
get { return dash0Style; }
set { dash0Style = value; }
}
/// <summary>
/// </summary>
[Description("Width for Line")]
[Category("Line Settings")]
[Gui.Design.DisplayNameAttribute("Line Width")]
public int Plot0Width
{
get { return plot0Width; }
set { plot0Width = Math.Max(1, value); }
}
#endregion
February 2nd, 2014, 01:51 PM
Columbus, OH
Market Wizard
Experience: None
Platform: NT 8, TOS
Trading: ES
Posts: 3,603 since Aug 2009
Thanks Given: 5,139
Thanks Received: 11,527
ceramictilepro
Very Nice! I'm using this one for sure!
Can you tell me if this can be attached to global drawing objects?
Thank You!
as far as I know, global drawing objects can't be accessed via ninja script.
I might be wrong, but I don't think so.
Last Updated on February 2, 2014