Need to draw vertical and horizontal lines - futures io
futures io futures trading



Need to draw vertical and horizontal lines


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one jsk123 with 2 posts (0 thanks)
    2. looks_two Quick Summary with 1 posts (0 thanks)
    3. looks_3 roelop with 1 posts (0 thanks)
    4. looks_4 gregid with 1 posts (2 thanks)
    1. trending_up 4,697 views
    2. thumb_up 2 thanks given
    3. group 4 followers
    1. forum 5 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Need to draw vertical and horizontal lines

(login for full post details)
  #1 (permalink)
Hyderabad,India
 
 
Posts: 86 since Oct 2013
Thanks: 40 given, 20 received

hello,

I have some price levels and certain dates (pre determined). I want to put that info into an indicator so that whenever I open the chart and load this indicator they are always there.

I tried to draw a vertical line on 17th march 2015, but it is not showing up. There are no errors in the code btw.

 
Code
 public class Dates : Indicator
    {
        #region Variables
        // Wizard generated variables
            private uint date; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #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()
        {
            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
            Overlay				= true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
 			 protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
			//           if (date == 20150317 && FirstTickOfBar)
			//			DrawVerticalLine("MyVerticalLine", 0, Color.Blue);
			if (ToTime(Time[0]) == 00000 && ToDay(Time[0]) == 20150317 && FirstTickOfBar) 
			
			DrawVerticalLine( "myTag", 20150317  , Color.Blue, DashStyle.Dash , 2);

Why is this not working ?

Also please mention how to draw lines at specific price levels using ninjascript

Reply With Quote

Can you help answer these questions
from other members on futures io?
Which kind of Blockvolume is visible? - order processing
Emini and Emicro Index
Cross border fund flows / fx correlations
Treasury Notes and Bonds
Automatic pattern research with NT
Elite Algorithmic NinjaTrader Trading
What blockvolume is visible? - order processing
NinjaTrader
Work with historical tcks data on MUltichart NET PowerLa …
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
110 thanks
Selling Options on Futures?
109 thanks
Rank your Futures vs Stocks trading priority
44 thanks
Want your NinjaTrader indicator created, free?
26 thanks
Bitcoin storage wallet recommendations
18 thanks
 
(login for full post details)
  #3 (permalink)
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 320 given, 620 received


Since you want to use the overload with date, you need to call the method with the following arguments:
 
Code
DrawVerticalLine(string tag, DateTime time, Color color, DashStyle dashStyle, int width)
In your code:
 
Code
DrawVerticalLine( "myTag", 20150317  , Color.Blue, DashStyle.Dash , 2);
you are not providing the DateTime but an int which is interpreted by NT as barsAgo, hence no error as it "draws" a line 20150317 bars ago. Read more on DateTime structure here:
C# DateTime Examples

Another problem in your code will be the tag which is not unique this will cause NT keeping only the last drawn line on the chart.

Try using the following:
 
Code
DrawVerticalLine("myVL" + 20150317, new DateTime(2015, 3, 17), Color.Blue, DashStyle.Dash, 2);
PS. For specific price level you probably want horizontal line, read here:
https://www.ninjatrader.com/support/helpGuides/nt7/index.html?drawhorizontalline.htm

Reply With Quote
The following 2 users say Thank You to gregid for this post:
 
(login for full post details)
  #4 (permalink)
Hyderabad,India
 
 
Posts: 86 since Oct 2013
Thanks: 40 given, 20 received

Thanks a lot gregid!! Didn't expect to do this so fast!

I messed around with the code and found that the integer no. after the tag is also not mandatory along with the 'dumb' if clause I used -_-

Thanks

 
Code
			//			DrawVerticalLine("MyVerticalLine", 0, Color.Blue);
//			if (ToTime(Time[0]) == 00000 && ToDay(Time[0]) == 20150317 && FirstTickOfBar) 
//			this if is useless piece of crap!!!
//			DrawVerticalLine( "myTag", 20150317  , Color.Blue, DashStyle.Dash , 2);
				DrawVerticalLine("myV3L" , new DateTime(2015, 3, 17), Color.Blue, DashStyle.Dash, 2);
				DrawVerticalLine("myVL" , new DateTime(2015, 3, 18), Color.Green, DashStyle.Dash, 2);
				DrawHorizontalLine("myhl", true,  162.125, Color.Red, DashStyle.Solid,  2);
				DrawVerticalLine("myVL4" , new DateTime(2015, 3, 23), Color.Green, DashStyle.Dash, 2);

Makes me feel that I cant do much relying solely on NT manual -_-


gregid View Post
Since you want to use the overload with date, you need to call the method with the following arguments:
 
Code
DrawVerticalLine(string tag, DateTime time, Color color, DashStyle dashStyle, int width)
In your code:
 
Code
DrawVerticalLine( "myTag", 20150317  , Color.Blue, DashStyle.Dash , 2);
you are not providing the DateTime but an int which is interpreted by NT as barsAgo, hence no error as it "draws" a line 20150317 bars ago. Read more on DateTime structure here:
C# DateTime Examples

Another problem in your code will be the tag which is not unique this will cause NT keeping only the last drawn line on the chart.

Try using the following:
 
Code
DrawVerticalLine("myVL" + 20150317, new DateTime(2015, 3, 17), Color.Blue, DashStyle.Dash, 2);
PS. For specific price level you probably want horizontal line, read here:
NinjaTrader Version 7


Reply With Quote
 
(login for full post details)
  #5 (permalink)
Denton, TX
 
Experience: Beginner
Platform: NinjaTrader
Trading: NQ, CL, AD
 
Posts: 1 since Nov 2016
Thanks: 0 given, 0 received

How to draw a global verticalline.

I want to draw a verticalline in multiple open chart.

This code is working well, but I want to draw this line in all my charts.

Draw.VerticalLine(this, @"buy " + CurrentBars[0].ToString(), 0, Brushes.Lime, DashStyleHelper.Solid, 2);

Thanks.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #6 (permalink)
Evans GA/USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader Brokerage - Philip Capital
Trading: NQ,ES,6E,CL
 
TradingOgre's Avatar
 
Posts: 550 since Jul 2018
Thanks: 902 given, 1,645 received


roelop View Post
How to draw a global verticalline.

I want to draw a verticalline in multiple open chart.

This code is working well, but I want to draw this line in all my charts.

Draw.VerticalLine(this, @"buy " + CurrentBars[0].ToString(), 0, Brushes.Lime, DashStyleHelper.Solid, 2);

Thanks.

If you are using NT 8, have you tried turning on global drawing objects? Tools->Options->General->Global Drawing Objects Across Workspaces.

not sure if that will work just something I noticed the other day.

Edit: Never mind. Just tried it and it didn't do what I thought.

Visit my futures io Trade Journal Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Need to draw vertical and horizontal lines


Last Updated on July 13, 2018


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts