![]() |
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 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,419
Thanks: 252
Thanked 981 times in 963 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Senior Member
|
Quote:
Code:
DrawTextFixed("InfoPanel", FirstLineOfText + "\n" +
NextLineOfText + "\n" +
NextLineOfText + "\n" +
NextLineOfText etc,.+ "\n" +
LastLineOfText,
this.InfoPanelPosition, TextColor, TextFont,
TextBoxOutlineColor, TextBackgroundColor, Transparency);
|
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
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 |
|
|
|
|
|
#5 |
|
Senior Member
|
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; 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" + Properly written, it should look something like the graphic attached.
Last edited by koganam; 03-20-2011 at 12:18 PM.
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Mar 2010
Posts: 320
Thanks: 87
Thanked 5 times in 5 posts
|
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 |
|
|
|
|
|
#7 |
|
Senior Member
|
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);
Last edited by koganam; 03-20-2011 at 01:09 PM.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |