NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-13-2008, 02:19 AM   #1
mgbloomfield
Senior Member
 
Join Date: Dec 2006
Location: Seattle, Washington, USA
Posts: 150
Thanks: 0
Thanked 0 times in 0 posts
Default Displaying the label for horizontal plot lines

I was comparing the Indicators that members have contributed (http://www.ninjatrader-support.com/v...1&sort=N&pp=15). In looking at the code, I've been unable to figure out how the labels are displayed differently.

In the "Floor Pivots" indicator, the labels are on top of the horizontal lines on the right side.

In the "SessionPivotsDaily V4" indicator, the labels are on the left side of the horizontal lines.

Where in the code do I find this?
mgbloomfield is offline  
Reply With Quote
Old 06-13-2008, 02:26 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

I suggest contacting the author(s) for clarification.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 06-14-2008, 06:35 PM   #3
mason
Member
 
Join Date: Feb 2008
Posts: 47
Thanks: 0
Thanked 0 times in 0 posts
Default

I was wondering the same thing, so here is my take
Session is using custom Plot
Quote:
int whiteBars = Math.Max(0, ChartControl.LastBarPainted - ChartControl.Bars[0].Count + 1);
int x = (int) (ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2 - (ChartControl.BarsPainted - 1) * ChartControl.BarSpace + (count - whiteBars) * ChartControl.BarSpace);

graphics.DrawString(plot.Name, ChartControl.Font, brush, lastX, lastY - ChartControl.Font.GetHeight() / 2, stringFormatFar);
Floor is also using custom Plot
Quote:
int x = (int) (ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2 - (ChartControl.BarsPainted - 1) * ChartControl.BarSpace + count * ChartControl.BarSpace);

graphics.DrawString("Floor " + plot.Name, ChartControl.Font, brush, firstX, lastY - ChartControl.Font.GetHeight(), stringFormat); //align label right
mason is offline  
Reply With Quote
Old 06-14-2008, 07:16 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

The use of custom plot is outside of the scope we can provide support for. Hint: Look for the x and y coordinate parameters on the DrawString. Those are the parameters that determine where the text will be print.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-24-2009, 12:04 PM   #5
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,825
Thanks: 12
Thanked 81 times in 67 posts
Default DataSeries holding DateTime values?

Just used graphics.DrawString to plot date labels next to Fibonacci lines.

To do this I defined a DataSeries array (such as standard "Values" series used by the Plot method), as the date labels are supposed to change along with the values. As DataSeries does not hold DateTime values, I converted DateTime to Int (using a reference date), then converted this to double, stored it on the DataSeries array and retrieved it within the graphics.DrawString method by reconverting it back to Int, then DateTime and finally String to plot it.

Is there any solution simpler than this, such as writing DateTime objects directly to a DataSeries?
Harry is offline  
Reply With Quote
Old 02-24-2009, 12:55 PM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Please see this article: http://www.ninjatrader-support.com/H...riesClass.html
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-24-2009, 01:01 PM   #7
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,825
Thanks: 12
Thanked 81 times in 67 posts
Default DateTimeSeriesClass

That is exactly what I was looking for. Did not know there was a DateTimeSeries class.

Quote:
Originally Posted by NinjaTrader_Josh View Post
Harry is offline  
Reply With Quote
Old 07-17-2009, 01:04 PM   #8
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,825
Thanks: 12
Thanked 81 times in 67 posts
Default Starting plot labels from the left

The graphics.DrawString method of the NT Pivot indicator plots labels from the right to the left. Is there any option to do it the other way round?

Alternatively, is there any function that returns the plotted length of a string - not mystring.Length which would return the number of characters, but the length of the string as plotted to the chart?
Harry is offline  
Reply With Quote
Old 07-17-2009, 01:33 PM   #9
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

Harry, to answer your first question: Not sure if there is an option to do it the other way around, but it is a standard .NET method. Here are the MSDN docs for Graphics.DrawString.

Second question: This might be possible (NinjaScript/NinjaTrader is C# so anything goes), but if it is possible it is not supported. Thank you for understanding.
NinjaTrader_Austin is offline  
Reply With Quote
Old 07-17-2009, 02:00 PM   #10
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,825
Thanks: 12
Thanked 81 times in 67 posts
Default Thank you.

Thanks for the hint. Digging a bit in MSDN showed that I just had to replace "StringFormatFar" with "StringFormatNear".
Harry is offline  
Reply With Quote
Old 07-17-2009, 02:29 PM   #11
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

Harry, that's great to hear. A little digging can go a long way.
NinjaTrader_Austin is offline  
Reply With Quote
Old 09-20-2009, 12:41 PM   #12
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,825
Thanks: 12
Thanked 81 times in 67 posts
Default Documentation of ChartControl

Is there any documentation of ChartControl methods available? For quite a number of indicators it is necessary to overwrite the existing Plot Class.
Harry is offline  
Reply With Quote
Old 09-20-2009, 02:59 PM   #13
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

Harry, there is not any ChartControl documentation available. Overriding the Plot class is unsupported.
NinjaTrader_Austin 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
Text on horizontal lines? Rocky Mtn Trader Charting 8 08-12-2008 04:47 PM
Horizontal Lines ale la juve ale Charting 1 03-25-2008 09:55 PM
Label the Horizontal Line mgbloomfield General Programming 1 10-24-2007 12:02 PM
Draw Horizontal Lines Richard Von Indicator Development 11 08-02-2007 12:23 PM
Horizontal Lines guym Suggestions And Feedback 2 12-07-2006 08:32 AM


All times are GMT -6. The time now is 05:14 PM.