NexusFi: Find Your Edge


Home Menu

 





N7 DrawLine not working


Discussion in NinjaTrader

Updated
    1. trending_up 1,733 views
    2. thumb_up 9 thanks given
    3. group 1 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

N7 DrawLine not working

  #1 (permalink)
 ceramictilepro 
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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Exit Strategy
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
18 thanks
The Program
18 thanks
  #3 (permalink)
 
Silvester17's Avatar
 Silvester17 
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 View Post
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

Reply With Quote
  #4 (permalink)
 ceramictilepro 
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 View Post
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


Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 
Silvester17's Avatar
 Silvester17 
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 View Post
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.

Reply With Quote




Last Updated on February 2, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts