Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing a simple line in an indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Drawing a simple line in an indicator

    Is there some special sauce I need to add to the recipe to draw a simple line? I'm experimenting with drawing objects for the very first time and the example taken from the NT7 language guide doesn't do a thing :-( here is my code:

    Code:
        public class LINEPROJECTOR : Indicator
        {
            #region Variables
    
                private int length = 25; // Default setting for Length
    
            #endregion
    
    
            protected override void Initialize()
            {
                Overlay				= true;
            }
    
    
            protected override void OnBarUpdate()
            {
    
    			DrawLine("tag1", false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Dot, 2);
    		
            }
    
            #region Properties
            [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            public DataSeries PlotH
            {
                get { return Values[0]; }
            }
    
            [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            public DataSeries PlotL
            {
                get { return Values[1]; }
            }
    
            [Description("Scope of detection")]
            [GridCategory("Parameters")]
            public int Length
            {
                get { return length; }
                set { length = Math.Max(8, value); }
            }
            #endregion
        }

    #2
    Hello ShruggedAtlas,
    Thanks for your post and I am happy to assist you.

    On which instrument you are putting up the indicator.

    The line is drawn on price level of 1000 to 1001. So if you are watching for example ES then you wont be able to see it.

    Also you need to check for the minimum bar requirement. Please refer to this post for further reference http://ninjatrader.com/support/forum...ead.php?t=3170

    A workable code will be
    Code:
    protected override void OnBarUpdate()
    {
            if (CurrentBar < 10) return;
    
    	DrawLine("tag1", false, 10, Close[0], 0, Close[0], Color.LimeGreen, DashStyle.Dot, 2);
    		
    }
    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Ok now i'm just plain embarrassed. I got it now. duh...I was applying it to SPY...duh

      Comment


        #4
        Hello ShruggedAtlas,
        Glad you could figure out the issue.

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X