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!
See more
See less

Partner 728x90

Collapse

Draw Line

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

    Draw Line

    I'm new with ninja script and try my first exercises ...
    I will draw a line in the chart , but it does't work...

    I use this code (the example from NT8 helpGuide) :

    ...
    protected override void OnBarUpdate()
    {
    Draw.Line(this, "tag1", false, 10, 12000, 0, 12020, Brushes.LimeGreen, DashStyleHelper.Dot, 2);
    }
    ....

    but nothing hapens..
    there is no line on the chart @ 12000

    the example for a horizontal line :

    Draw.HorizontalLine(this, "tag1", 1000, Brushes.Black);

    works perfectly...

    what is wrong ?
    thanks for any answer...

    #2
    Hello jr123,

    I'm seeing that you are referring to NinjaTrader 8 and I have moved your thread from the NinjaTrader 7 Indicator Development section on the forums over to the NinjaTrader 8 Indicator Development section of the forums.

    I've added the line of code to a script and tested but I am not able to reproduce your results.

    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      still no line

      Thank you for the answer...

      but same Video from me :



      but still there is no line ...

      I have try this with Fdax and with ES like you...
      no line

      what is wrong ?
      Last edited by jr123; 03-20-2017, 01:49 PM.

      Comment


        #4
        i have try the same thing with another PC. NT8 new installed.
        Draw.Line still doesn't work. Why ?

        Code:
        #region Using declarations
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Windows;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Xml.Serialization;
        using NinjaTrader.Cbi;
        using NinjaTrader.Gui;
        using NinjaTrader.Gui.Chart;
        using NinjaTrader.Gui.SuperDom;
        using NinjaTrader.Gui.Tools;
        using NinjaTrader.Data;
        using NinjaTrader.NinjaScript;
        using NinjaTrader.Core.FloatingPoint;
        using NinjaTrader.NinjaScript.DrawingTools;
        #endregion
        
        //This namespace holds Indicators in this folder and is required. Do not change it. 
        namespace NinjaTrader.NinjaScript.Indicators
        {
        	public class DrawLineTest : Indicator
        	{
        		protected override void OnStateChange()
        		{
        			if (State == State.SetDefaults)
        			{
        				Description									= @"Enter the description for your new custom Indicator here.";
        				Name										= "DrawLineTest";
        				Calculate									= Calculate.OnBarClose;
        				IsOverlay									= true;
        				DisplayInDataBox							= true;
        				DrawOnPricePanel							= true;
        				DrawHorizontalGridLines						= true;
        				DrawVerticalGridLines						= true;
        				PaintPriceMarkers							= true;
        				ScaleJustification							= NinjaTrader.Gui.Chart.ScaleJustification.Right;
        				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
        				//See Help Guide for additional information.
        				IsSuspendedWhileInactive					= true;
        			}
        			else if (State == State.Configure)
        			{
        			}
        		}
        
        		protected override void OnBarUpdate() 
        		{
        			Draw.Line(this, "tag1", false, 10, 12000, 0, 12020, Brushes.LimeGreen, DashStyleHelper.Dot, 2);
        		}
        	}
        }
        
        #region NinjaScript generated code. Neither change nor remove.
        
        namespace NinjaTrader.NinjaScript.Indicators
        {
        	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        	{
        		private DrawLineTest[] cacheDrawLineTest;
        		public DrawLineTest DrawLineTest()
        		{
        			return DrawLineTest(Input);
        		}
        
        		public DrawLineTest DrawLineTest(ISeries<double> input)
        		{
        			if (cacheDrawLineTest != null)
        				for (int idx = 0; idx < cacheDrawLineTest.Length; idx++)
        					if (cacheDrawLineTest[idx] != null &&  cacheDrawLineTest[idx].EqualsInput(input))
        						return cacheDrawLineTest[idx];
        			return CacheIndicator<DrawLineTest>(new DrawLineTest(), input, ref cacheDrawLineTest);
        		}
        	}
        }
        
        namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
        {
        	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        	{
        		public Indicators.DrawLineTest DrawLineTest()
        		{
        			return indicator.DrawLineTest(Input);
        		}
        
        		public Indicators.DrawLineTest DrawLineTest(ISeries<double> input )
        		{
        			return indicator.DrawLineTest(input);
        		}
        	}
        }
        
        namespace NinjaTrader.NinjaScript.Strategies
        {
        	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        	{
        		public Indicators.DrawLineTest DrawLineTest()
        		{
        			return indicator.DrawLineTest(Input);
        		}
        
        		public Indicators.DrawLineTest DrawLineTest(ISeries<double> input )
        		{
        			return indicator.DrawLineTest(input);
        		}
        	}
        }
        
        #endregion

        Comment


          #5
          Hello jr123,

          Please send an email to platformsupport [at] ninjatrader [dot] com so that I may test with you on your end.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            the answer :

            It appears the script is having an error based on the data being used.

            You are currently using a 10 BarsAgo value but not checking if there are 10 Bars before calling this code. On Bars 0 — 9 this code would have an error but the script would just stop processing on bar 0 because of this.

            To resolve the error, please add the following code into OnBarUpdate before drawing:


            protected override void OnBarUpdate()
            {
            if(CurrentBar < 10) return;
            Draw.Line(this, "tag1", false, 10, Close[0], 0, Close[0], Brushes.LimeGreen, DashStyleHelper.Dot, 2);
            }


            thanks to :
            Jesse ... NinjaTrader Platform Customer Service
            great service !

            Comment


              #7
              Hi jr123,

              I overlooked that when I didn't get an error when testing.

              I've given Jesse a nudge and thanks.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              604 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              3 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              470 views
              0 likes
              Last Post tradingnasdaqprueba  
              Started by aa731, Today, 02:54 AM
              0 responses
              5 views
              0 likes
              Last Post aa731
              by aa731
               
              Started by Christopher_R, Today, 12:29 AM
              0 responses
              11 views
              0 likes
              Last Post Christopher_R  
              Working...
              X