![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_RyanM for this post: |
|
|
|
#3 |
|
Junior Member
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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);
Ryan M
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_RyanM for this post: |
|
|
|
#5 |
|
Junior Member
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
|
Mistyped:
in my indicator I try to plot them as follows: DrawLine("Lines" + CurrentBar, 0, <MyHigh>, 0, <MyLow>, Color.Blue); |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
For basic C# syntax, I would check out the following link:
http://www.ninjatrader.com/support/h...sic_syntax.htm Example with doubles: double myHigh = SMA(5)[0]; double myLow = Low[0]; Then refer in code with just myHigh or myLow. (no extra < or > needed)
Ryan M
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_RyanM for this post: |
|
|
|
#8 |
|
Senior Member
|
|
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
|
Hi Kogaman and Ryan,
The pointy brackets mean nothing. I mistyped. I did not use them in my code. I come from a programming background and that is a way write pseudocode. Anyway, What I was trying to ask was that, in my indicator I have 2 variables that I've declared as Double in the OnBarUpdate() procedure as follows: double MyHigh; double MyLow; // I did some calculations to populate MyHigh and MyLow variables //Now what I want to do is print a vertical line between MyHigh and MyLow //When I use the Drawline as Ryan suggested DrawLine("Lines" + CurrentBar, 0, MyHigh, 0, MyLow, Color.Blue); //I get the following errors: Use of unassigned local variable MyHigh Use of unassigned local variable MyLow Any ideas what I'm doing wrong? From my 1 day experience with NinjaScript, it seems like it is expecting a dataseries (i.e. an array of doubles). For example if I use DrawLine("Lines" + CurrentBar, 0, High[0], 0, Low[0], Color.Blue); it compiles fine. Thanks for helping. |
|
|
|
|
|
#10 | |
|
Senior Member
|
Quote:
|
|
|
|
|
|
The following 2 users say thank you to koganam for this post: |
|
|
|
#11 |
|
Junior Member
Join Date: Jul 2012
Posts: 12
Thanks: 6
Thanked 1 time in 1 post
|
That did the trick. Thanks a lot koganam. Really appreciate it.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |