![]() |
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: Jul 2006
Location: Los Angeles, California, USA
Posts: 136
Thanks: 0
Thanked 0 times in 0 posts
|
I have an indicator displaying 123.00 and I want it to just show 123
Can anyone show me how to make a double convert to an integer, and ALSO display as an integer. (I have also tried the Convert.Int32 way of doing it and that had same results.) Right now it is: -Variables: private double cciValue = 0; -Performed every tick update after "Period" number of bars: cciValue = (int)cciData[0]; -Down where it actually asks for it to display: graphics.DrawString(cciValue.ToString("f2"), Is there something different than "f2" that I can insert to try to make it display just the integer without decimals? I can't understand the syntax on the various websites that suggest {0:n} and the like. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Sorry, would not know of the top of my head. I suggest consulting the Microsoft documentation on the ToString() method.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jun 2006
Posts: 111
Thanks: 0
Thanked 1 time in 1 post
|
You can replace "f2" with "f0", or as you are using an integer I think you can try leaving the bracket empty .ToString()
|
|
|
|
|
|
#4 | |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
Quote:
Code:
Print( String.Format( "High={0} Low={1} Open={2} Close={3}",
High[0], Low[0], Open[0], Close[0]
)
);
The number in the curly braces is the number of the parameter to be substituted into the format string, so "{0}" gets replaced with the first parameter (in this case the value of High[0]) and the "{1}" gets replaced with the second parameter (Low[0]), etc. Note that the following will display the same output as the above example... Code:
Print( String.Format( "High={3} Low={1} Open={2} Close={0}",
Close[0], Low[0], Open[0], High[0]
)
);
Code:
Print( String.Format( "Bar={0:D2} Close={3:F2} Value={4:F2} Cur={1:F2} Last={2:F2}",
CurrentBar, Cur, Last, Close[0], Value[0]) );
(Note the above parameters are out of order... I must have decided to insert something in the middle of the format string and didn't want to renumber everything.)
There are lots of other variations that can be used. Here are a couple of links to some MSDN .NET documentation that tells lots more: http://msdn.microsoft.com/library/de...matstrings.asp, http://msdn2.microsoft.com/en-us/library/txafckwd(vs.71).aspx Although you may find the following references more readable: http://blog.stevex.net/index.php/str...ing-in-csharp/ http://blogs.msdn.com/kathykam/archi...29/564426.aspx http://idunno.org/archive/2004/14/01/122.aspx |
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jul 2006
Location: Los Angeles, California, USA
Posts: 136
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visually display Bid/Ask | sbgtrading | NinjaScript File Sharing Discussion | 5 | 06-18-2008 03:17 PM |
| How to display Bid/Ask on the Y axis | asalada | Miscellaneous Support | 1 | 04-10-2008 04:51 AM |
| FX Entry Decimals | trader2be | Connecting | 2 | 12-13-2007 09:24 PM |
| Column Display | Ronin | Market Analyzer | 4 | 09-07-2007 01:51 PM |
| fractions/decimals | Gar | Miscellaneous Support | 3 | 05-24-2005 03:07 AM |