NinjaTrader Support Forum  

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

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 05-10-2008, 12:47 PM   #1
higler
Senior Member
 
Join Date: Apr 2007
Location: Longmont, Colorado, USA
Posts: 296
Thanks: 4
Thanked 3 times in 3 posts
Default Positioning text using DrawText()

I am drawing an UpArrow on my chart at various locations. I would like to draw text at a fixed distance below the arrow. Can someone tell me how to do this? I am drawing the arrow at Low[0] - .5 * TickSize. If I position the text at a multiple of TickSize such as Low[0] - 2 * TickSize then the distance below the arrow varies depending on how compressed the chart gets when there are large price variations. I would like the text to be a fixed distance below the arrow always. Thanks.
higler is offline  
Reply With Quote
Old 05-10-2008, 02:36 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please take a look at this syntax version for DrawText()

DrawText(string tag, bool autoScale, string text, int barsAgo, double y, double yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color backColor, int opacity)

I think the yPixelOffest parameter can be useful in your case.
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-14-2008, 02:14 PM   #3
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 hmm, please explain DrawText() positioning...

I'm using this:
DrawText("ask", false, "Ask: "+askRows[0].Price + " Vol: "+askRows[0].Volume, 0, High[0], 100, Color.Red, font, StringAlignment.Far, Color.Transparent, Color.Transparent, 50);

I want the text to be the X= 5 (five bars back from currentbar), and Y = HighestBar(High, 20) but whenever I use those values I see NO text anywhere. If I plugin the above values they show up ok.
funk101 is offline  
Reply With Quote
Old 07-15-2008, 12:13 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Try this code instead:
Code:
DrawText("test", false, "Test Text", 5, MAX(High, 20)[0], Color.Red, new Font("Arial", 12), StringAlignment.Far, Color.Transparent, Color.Transparent, 50);
The 5 is for the x axis and you want to use the MAX() to find the highest high instead of HighestBar().
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-15-2008, 12:32 AM   #5
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 re:

Well, the problem is the "5", unless I use "0" for X, I don't see it. Why? I tried your code, did not see it, I replaced 5 with 0 and it shows up.
funk101 is offline  
Reply With Quote
Old 07-15-2008, 12:48 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Check your Control Center logs. You most likely need to put in a
Code:
if (CurrentBar < 5)
     return;
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-15-2008, 01:34 AM   #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 re: that was it

Yes. Ok, so can I get the data to update like T&S? Instead of just OnBarUpdate()? I want to get the bid and ask, as they come in, not wait till chart updates it, is that possible?
funk101 is offline  
Reply With Quote
Old 07-15-2008, 01:36 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Sure. Check out the advanced methods OnMarketData() or OnMarketDepth().
NinjaTrader_Josh 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
DrawText API doc? mazachan General Programming 1 03-04-2008 03:12 PM
DrawText Mike Winfrey General Programming 1 12-21-2007 04:57 PM
Vertical positioning ralph.ronnquist Indicator Development 1 12-07-2007 10:39 PM
DrawText, DrawLine, etc... funk101 Indicator Development 2 05-27-2007 01:13 PM
Positioning of Manually Drawn Objects whitmark Charting 1 03-27-2007 05:59 AM


All times are GMT -6. The time now is 11:45 PM.