NinjaTrader Support Forum  
X

Attention!

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


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

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 08-27-2010, 11:07 AM   #1
trader2be
Member
 
Join Date: Nov 2007
Posts: 63
Thanks: 0
Thanked 0 times in 0 posts
Default Drawing text in indicator panel

I draw four horizontal dotted lines in an indicator panel (values 0, 0.5, 1, and 1.5), and I change the colors for each bar depending on price action. I would add to add a label (text) to the left on each of those lines to indicate their function. I would obviously like for the label to remain in the same place (left-most side of the indicator panel) as I scroll through time. How do I do this?
trader2be is offline  
Reply With Quote
Old 08-27-2010, 11:17 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

You can set DrawOnPricePanel to false and then use DrawTextFixed() with a left side alignment -

http://www.ninjatrader-support.com/H...TextFixed.html
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 08-27-2010, 01:50 PM   #3
trader2be
Member
 
Join Date: Nov 2007
Posts: 63
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi, unfortunately the suggestion doesn't work for what I am trying to do. I have attached a screen print to show you my indicator (http://www.screencast.com/t/Yjk1MjMwM). As you can see it displays five lines of diamonds. I would like to ask a word of text to the left of those lines of diamond to explain which study the line relates to. DrawText may be the solution and the y value is not a problem, however I don't know how to reference the x/time value to coincide with the left most side of the screen. Thanks in advance for your help.

trader2be is offline  
Reply With Quote
Old 08-27-2010, 02:01 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

You have to use DrawTextFixed() if you want it to correspond with left edge as opposed to a certain bar. DrawText() is tied to bars and as you scroll around it will move while DrawTextFixed() is "fixed" onto the chart on certain corners.

If you want it to be "fixed" but at locations of your choosing unfortunately this is not supported and you would have to override the Plot() method and custom program that in yourself.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-27-2010, 02:09 PM   #5
trader2be
Member
 
Join Date: Nov 2007
Posts: 63
Thanks: 0
Thanked 0 times in 0 posts
Default

Any good example out there of overriding the Plot() method?
trader2be is offline  
Reply With Quote
Old 08-27-2010, 03:13 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

Overriding the Plot() method is outside the scope of what we can offer support for and we unfortunately do not have any samples.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-26-2011, 12:28 PM   #7
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Default Overriding Plot() in panel 2...

I just would like to know *if it is possible* to override Plot() in panel 2? I know "how" to do it just want to know if it is possible, yes or no.
funk101 is offline  
Reply With Quote
Old 06-26-2011, 12:32 PM   #8
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Default

I'll answer that -> yes it is
funk101 is offline  
Reply With Quote
Old 06-27-2011, 09:31 AM   #9
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,202
Thanks: 24
Thanked 1,228 times in 999 posts
Send a message via Skype™ to koganam
Default

The x-coordinate value for the left side of the screen would be ChartControl.FirstBarPainted, so the value you would use for the startBarsAgo witl be (CurrentBar - ChartControl.FirstBarPainted).

Example:


Code:
int LeftSideOfScreen = ChartControl.FirstBarPainted;
DrawText("Test", false, "Text to show at left side of screen", 
(CurrentBar - LeftSideOfScreen), Close[0], 0, Color.Blue, new Font("Arial" , 12), 
StringAlignment.Near, Color.Transparent, Color.Transparent, 5);
Since you are going to be using that line a whole lot, you should probably initialize the font in OnStartUp(), after declaring it in the Variables region, and then dispose of the font in OnTermination().

Be aware that all use of ChartControl functions will not get any support from NT, so use at your own risk. It could change in the future, which I am sure, is partly why they refuse to provide any support for it.
Last edited by koganam; 06-27-2011 at 09:37 AM.
koganam is online now  
Reply With Quote
Old 06-27-2011, 09:39 AM   #10
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,202
Thanks: 24
Thanked 1,228 times in 999 posts
Send a message via Skype™ to koganam
Default

Just remember to check for Bounds.Max and Bounds.Min in the panel where you are overriding the plot.
koganam is online now  
Reply With Quote
Old 07-29-2011, 04:30 PM   #11
piptek
Junior Member
 
Join Date: May 2011
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

Nice example.... thanks Koganam
piptek 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
Drawing in Indicator panel Tremblinghandtrader Indicator Development 4 04-27-2010 12:49 AM
Drawing Arrows and Text in Price or Indicator area BobTN Indicator Development 12 02-28-2010 10:59 AM
Drawing a single dot in indicator panel zacharydw00 Indicator Development 7 07-21-2009 03:22 PM
Chart Panel for Text Only BillCh General Programming 3 04-22-2009 01:11 PM
Developing an indicator that displays only text in Panel 2 thru N Jim W. Indicator Development 6 02-11-2009 07:01 AM


All times are GMT -6. The time now is 10:23 AM.