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 03-18-2011, 01:32 AM   #1
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default DrawText Issues and DrawtextFixed

Hi Guys, I've been getting a little frustrated trying to draw/position text on the chart and was hoping you could tell me an easier way. Please find attached the chart and look at the text on the right in Yellow - Low High Ratio etc. How I do this is with the following code from the manual which draws this one 5 across and 20 up from the close of the last bar:

DrawText("5", true, "Delta:", -6, High[0] +20 * TickSize ,15, Color.Yellow, largeFont, StringAlignment.Near, Color.Transparent, Color.Green, 0);

Now the problem with this code is it all moves as the candles move so can end up getting squashed at the top of the chart. What I am trying to do is anchor this at the top right as the chart moves it stays put. Ideally the drawtextfixed should come to the rescue but that only seems to allow one item at the corners not going down the page like I have. Ideally you could have a drawtextfixedright -1 and -2 etc so can be position down the page. So hopefully you can advise me a more effective way of doing this? Thanks. DJ
Attached Images
File Type: jpg Draw Text Issues TF 06-11 (10 BetterRenko) 3_18_2011.jpg (123.4 KB, 35 views)
djkiwi is offline  
Reply With Quote
Old 03-18-2011, 05:26 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,419
Thanks: 252
Thanked 981 times in 963 posts
Default

Hi DJ, you're correct in assuming the DrawTextFixed would only help you here if you could put all your custom info in one DrawTextFixed object, not several ones - perhaps the ideas working into the custom status box from the sharing section can help you out - http://www.ninjatrader.com/support/f...=status&desc=1
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-19-2011, 03:42 AM   #3
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Cool

Quote:
Originally Posted by djkiwi View Post
Hi Guys, I've been getting a little frustrated trying to draw/position text on the chart and was hoping you could tell me an easier way. Please find attached the chart and look at the text on the right in Yellow - Low High Ratio etc. How I do this is with the following code from the manual which draws this one 5 across and 20 up from the close of the last bar:

DrawText("5", true, "Delta:", -6, High[0] +20 * TickSize ,15, Color.Yellow, largeFont, StringAlignment.Near, Color.Transparent, Color.Green, 0);

Now the problem with this code is it all moves as the candles move so can end up getting squashed at the top of the chart. What I am trying to do is anchor this at the top right as the chart moves it stays put. Ideally the drawtextfixed should come to the rescue but that only seems to allow one item at the corners not going down the page like I have. Ideally you could have a drawtextfixedright -1 and -2 etc so can be position down the page. So hopefully you can advise me a more effective way of doing this? Thanks. DJ
Code:
DrawTextFixed("InfoPanel",	FirstLineOfText + "\n" +
					NextLineOfText + "\n" +
					NextLineOfText + "\n" +
					NextLineOfText etc,.+ "\n" +
					LastLineOfText,
					this.InfoPanelPosition, TextColor, TextFont, 
					TextBoxOutlineColor, TextBackgroundColor, Transparency);
koganam is offline  
Reply With Quote
Old 03-20-2011, 03:04 AM   #4
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default Draw text with panel box

Thanks Guys for posting that and especially that last part Koganam. I am not really sure what that does until I see it on the chart. So far I have this:

DrawTextFixed("InfoPanel", "Low" + "\n" +
EMA(gcd.DeltaClose,5)[0].ToString("N0") + "\n" +
"High" + "\n" +
"Ratio" + "\n" +
"Delta",
this.InfoPanelPosition,Color.Red, largeFont,
Color.White, Color.Blue, 10);


I am getting an error that says does not contain a definition for infoPanelPosition and no extension method InfoPanelPostion" Accepting a first argument. So I tried to define it in variables with:

private InfoPanelPosition = TextPosition.TopRight;

then it said class member declaration expected.

Not really sure what to do next. I assume I have to define InfoPanelPosition as top right somewhere so that is where the text starts? Thanks. DJ
djkiwi is offline  
Reply With Quote
Old 03-20-2011, 05:56 AM   #5
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

From what you write, I presume that you have already defined largeFont.

The InfoPanelPosition is of type TextPosition, so should be properly declared as:

Code:
private TextPosition InfoPanelPosition = TextPosition.TopRight;
or, as "InfoPanelPosition" was meant as a placeholder anyway, (just like "TextColor" et. al.,) just write it into place directly. You would only really need to declare it as a variable, if you want to make it a user selectable parameter for the indicator.

You also need to write your lines correctly. "Low" will simply print that on the screen, I am going to presume that you mean to write the line to show the Low, and identify it. That would need to be written thus:

Code:
"Low: " + Low[0] + "\n" +
etc

Properly written, it should look something like the graphic attached.
Attached Images
File Type: png InfoPanel.png (237.6 KB, 35 views)
Last edited by koganam; 03-20-2011 at 12:18 PM.
koganam is offline  
Reply With Quote
Old 03-20-2011, 09:31 AM   #6
djkiwi
Senior Member
 
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
Default Draw Text Fixed Scene 3

Thanks. That is exactly what I was after! The only question I have remaining is how do I set the fonts and backgrounds for each individual line. For example I have this example right now:

DrawTextFixed("InfoPanel", "Low: " + EMA(Close,5)[0].ToString("N0") + "\n" +
"Ratio: " + EMA(gcd.DeltaClose,5)[0].ToString("N0") + "\n" +
"High: " + High [0].ToString("N0") + "\n" +
" " + "\n" +
"Ratio: " + Close [0].ToString("N0") + "\n" +
"Delta: ",
this.InfoPanelPosition,Color.Red, largeFont,
Color.White, Color.Blue, 10);

Now the InfoPanelPostion sets all of this for all the parameters. Say I wanted to have The word ratio in Yellow and, the Close [0] in white and Background of close 0 in green like I have in this attached chart.

For example when I used drawtext it allowed me set these things as follows:

DrawText("6", true, "Swing:", -6, High[0] +0 * TickSize ,15, Color.Yellow, largeFont, StringAlignment.Near, Color.Transparent, Color.Green, 0);

Thanks DJ
Attached Images
File Type: jpg Draw Text Fixed TF 06-11 (10 BetterRenko) 3_18_2011.jpg (114.1 KB, 26 views)
djkiwi is offline  
Reply With Quote
Old 03-20-2011, 12:16 PM   #7
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

To do that you would have to write each line individually with a separate DrawTextFixed, and use "\n"'s to space the text out vertically. Now that you have the idea, I am sure that you can run with this.

Code:
DrawTextFixed("InfoPanel1", FirstLineOfText,
					  this.InfoPanelPosition, TextColor1, TextFont1, 
					 TextBoxOutlineColor1, Color.Transparent, 0);
DrawTextFixed("InfoPanel2", "\n" + NextLineOfText,
					  this.InfoPanelPosition, TextColor2, TextFont2, 
					 TextBoxOutlineColor2, Color.Transparent, 0);
DrawTextFixed("InfoPanel3", "\n\n" + NextLineOfText,
					  this.InfoPanelPosition, TextColor3, TextFont3, 
					 TextBoxOutlineColor3, InfoPanelBackgroundColor, Transparency);
et.c.,
Last edited by koganam; 03-20-2011 at 01:09 PM.
koganam 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
DrawTextFixed BigMike Indicator Development 7 04-01-2010 10:01 AM
Adding HREF to DrawText or DrawTextFixed i001962 Indicator Development 1 01-02-2010 01:44 AM
DrawTextFixed murfinp General Programming 1 04-08-2009 07:08 AM
DrawTextFixed gg80108 Suggestions And Feedback 1 03-31-2009 11:49 AM
DrawText and DrawTextFixed TAJTrades General Programming 8 12-19-2008 10:24 AM


All times are GMT -6. The time now is 07:02 AM.