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 > Indicator Development

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

Reply
 
Thread Tools Display Modes
Old 01-19-2012, 08:37 PM   #1
Taddypole
Senior Member
 
Join Date: Mar 2007
Location: , ,
Posts: 234
Thanks: 1
Thanked 2 times in 2 posts
Default Format DateTIme String in DrawText for min and seconds

I'm trying to format a DateTime string in a DrawText object. It compiles but doesn't do any special formatting.

DrawText("BarTimeDn", String.Format("{0:m mm}",ElapsedTime),-2,Volume[0]/2,Color.Black); // Write BatTime to chart

In the attached picture you can see the output is of the form: 00:00:00 - or hh:mm:ss. I actually want mm:ss.

The variable "ElapsedTime" is a TImeSpan variable. Is that the problem? Does the String.Format() only work on DateTime variables?

regards,

taddypole...
Attached Images
File Type: png BarTime for Volume Bars.png (27.9 KB, 13 views)
Taddypole is offline  
Reply With Quote
Old 01-20-2012, 01:51 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Yes Taddypole, I believe you would need to convert the Timespan first to DateTime and then could apply your String.Format customizations for display.
NinjaTrader_Bertrand 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
Release 8. Half way fix of datetime format ? zweistein Charting 7 09-10-2012 03:56 AM
About the text format of DrawText method keven General Programming 6 02-18-2011 07:27 PM
Does DrawText auto-trim a string? marketmasher General Programming 5 04-15-2009 09:39 AM
Input string was not in a correct format auto9817 Connecting 23 02-27-2009 05:21 AM
String in incorrect format Burga1 General Programming 2 05-07-2008 12:04 PM


All times are GMT -6. The time now is 12:41 PM.