NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 07-20-2012, 01:26 PM   #1
vsolv
Junior Member
 
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
Default Vertical Bar

Is it possible to draw a vertical line between 2 indicators. For example, if I have 2 moving averages on the chart and I want to draw a vertical line between them, is it possible?

I'm transitioning from traderstation and they had a feature called Paintbar which would allow me to pass a high value and a low value and it would paint a vertical bar on the chart.

Hoping someone can help.
vsolv is offline  
Reply With Quote
Old 07-20-2012, 01:33 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi vsolv,

Yes, you could use DrawLine(), which has startY and endY inputs:
http://www.ninjatrader.com/support/h...7/drawline.htm

You may want to check out DrawRegion() as well. There's a sample showing how to work it between Bollinger lines here:
http://www.ninjatrader.com/support/f...ead.php?t=4331
NinjaTrader_RyanM is offline  
Reply With Quote
The following user says thank you to NinjaTrader_RyanM for this post:
Old 07-20-2012, 02:13 PM   #3
vsolv
Junior Member
 
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
Default

When using the Drawline
startY - The starting y value co-ordinate where the draw object will be drawn
EndY - The end y value co-ordinate where the draw object will be drawn

Drawline is expecting me to provide the StartY and EndY values. I'm guessing that the coordinate system is in pixels. So question is, how do I take my indicator's High and Low values and convert it to the proper Y coordinate ?

Sorry --- newbie here and just learning NScript.
vsolv is offline  
Reply With Quote
Old 07-20-2012, 02:27 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

StartY and EndY are the values of your moving averages. Let's say you have a 5 period and 50 period SMA. You would draw lines between them with something like this:

Code:
DrawLine("Lines" + CurrentBar, 0, SMA(5)[0], 0, SMA(50)[0], Color.Blue);
This can be a bit of a performance drain, so I would also take a look at that DrawRegion sample which can do this sort of thing with more efficiency.
NinjaTrader_RyanM is offline  
Reply With Quote
The following user says thank you to NinjaTrader_RyanM for this post:
Old 07-20-2012, 03:43 PM   #5
vsolv
Junior Member
 
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
Default

Apologize for these newbie questions.
In my indicator, I have 2 local variables that I'm trying to plot.
MyHigh, MyLow - these are double

I do my calculations to populate these in the indicator.

when I try to plot them as follows:

DrawLine("Lines" + CurrentBar, 0, <MyLocalVar_High>, 0, <MyLocalVar_Low>, Color.Blue);

I get the following errors:

Use of unassigned local variable MyHigh
Use of unassigned local variable MyLow


What am I doing wrong? Can someone help.
vsolv is offline  
Reply With Quote
Old 07-20-2012, 03:46 PM   #6
vsolv
Junior Member
 
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
Default

Mistyped:

in my indicator I try to plot them as follows:

DrawLine("Lines" + CurrentBar, 0, <MyHigh>, 0, <MyLow>, Color.Blue);
vsolv is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vertical Bar Indicator freeway Indicator Development 1 10-29-2011 10:08 AM
TPO and Volume Profile Chart vertical scroll bar arodrigu Version 7 Beta General Questions & Bug Reports 2 03-25-2010 07:49 AM
Range bar vertical gaps ? supertrader Charting 40 12-03-2009 02:38 PM
Drawing 2 Vertical Lines on Same Bar ATLien Indicator Development 1 07-26-2008 12:02 PM
Vertical through all levels Antraman Charting 2 04-24-2006 01:10 AM


All times are GMT -6. The time now is 01:32 AM.