Print(String.Format("Close:{0} High:{1:0.00}", Close[0], High[0]));
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Print() syntax
Collapse
X
-
You can also try stuff like this to simulate %s/printf from C/C++:
Code:
-
Thank you for the links.
Is there any way to have 2 different formats on one line?
For example, in your post from your first link is there any way to combine:
Print(“Formatted to 2 decimal places: ” + c.ToString(“N2”));
Print(“Formatted to 3 decimal places: ” + c.ToString(“N3”));
so that the line in the output window reads:
Formatted to 2 decimal places: 10.26 Formatted to 3 decimal places: 10.257
instead of having it print on a different line each time?
Thanks.
Originally posted by NinjaTrader_Josh View PostHi,
You will want to use Position.AvgPrice.ToString("N2").
To format your DateTime object please see this article: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Leave a comment:
-
Hi,
You will want to use Position.AvgPrice.ToString("N2").
To format your DateTime object please see this article: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Leave a comment:
-
Aligning prices
In the help file, it says:
Tips
1. You can align prices to be formatted for easier debugging such as Low[0].ToString("0.00"). So if you have
12.5
12.75
you would get
12.50
12.75
Is there any way to apply this with interspersed text and variables?
For example, can I get the code below to print out the average price in a XXXX.XX format so the time stamps line up?
For that matter, is there a way to format the time stamp so the implied 0 in front of single digit hours shows?
Print(Position.MarketPosition +" from "+ Position.AvgPrice +" at " + Time[0].ToString());
Currently I get:
Long from 1299.5 at 8/12/2008 9:30:00 AM
Long from 1295.75 at 8/12/2008 11:00:00 AM
And I would like it to look like:
Long from 1299.50 at 8/12/2008 09:30:00 AM
Long from 1295.75 at 8/12/2008 11:00:00 AM
Thank you,
DK
Leave a comment:
-
In C# you do not need to use the % syntaxing for the variables like in C. You can just call your variable and use .ToString() on it to get it to print.
Leave a comment:
-
Anything similar to printf()?
Any ability to insert variables with %d, %s, etc. into the strings?
I have looked on Google...
Leave a comment:
-
Print(variable1 + " " + variable2 + " " + variable3);
If you only wanted to print one variable you could do this:
Print(variable1.ToString());
MSDN and google are great places to find information on C#.
Leave a comment:
-
Print() syntax
I'd like to print out different values in colums, something like
Print(variable1, variable2, variable3).
What is the correct syntax I can use?
More generally, do you have a link for C# function references?
Thank youTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by spottysallrite, Today, 11:31 AM
|
0 responses
0 views
0 likes
|
Last Post Today, 11:31 AM | ||
Started by johnMoss, 03-04-2024, 01:53 PM
|
2 responses
29 views
0 likes
|
Last Post
by Overnhou
Today, 11:21 AM
|
||
Started by Padan, Today, 02:02 AM
|
5 responses
16 views
0 likes
|
Last Post Today, 11:14 AM | ||
Started by Lele2k24, Yesterday, 11:24 AM
|
8 responses
28 views
0 likes
|
Last Post
by Lele2k24
Today, 11:00 AM
|
||
Started by kramnor2001, Yesterday, 02:30 PM
|
4 responses
24 views
0 likes
|
Last Post
by bltdavid
Today, 10:44 AM
|
Leave a comment: