Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
RoundToTickSize
Collapse
X
-
RoundToTickSize
Hi, I am trying to use this command but can't figure out how to do it correctly. NT8 Help Guide says only "NEEDS EXAMPLE" . I am trying to limit the decimals in my Ninjascript output table and wanted to use this command. Any idea how to accomplish that? Thank you so muchTags: None
-
Hi Chelsea,
Thanks for the feedback, I tying to print to output window.
(myDouble.ToString()) - I put this in front of my code I want to print?
Somehow I cant get the full link but it is easy to find:
NT8 Helpguide - Ninjascript - Alphabetical Reference - R - RoundToTickSize
Comment
-
Hello JBU1314,
No, you would use Print() to print. And use .ToString() on a double when printing this or concatenating with another string.
myDouble is an example of a variable name. This would be whatever variable you are trying to print.
Below is a link to a video that demonstrates prints.
World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.
Below I am providing the link to the help guide page in question.
As an example try:
Print(Instrument.MasterInstrument.RoundToTickSize( 100.31).ToString());Chelsea B.NinjaTrader Customer Service
Comment
-
Chelsea, I am trying to implement your suggestion but cant seem to make much progress. Here my code:
I want to round to 2 decimals with date / time /etc. I have shortcut i use:
private void P(string msg)
{
Print(Time[0].ToShortDateString() + " " + Time[0].ToShortTimeString() + ":" + msg);
}
So a sample message I want to round is the current ATR level at entry:
P("ATR at Entry is:" + _atr[0]);
Where would I implement the rounding command? I tried everything and there is no example in the help guide.
Thanks
Comment
-
Thank you for these added details JBU1314. To print a decimal out to 2 places, we can use a format string :
This publicly available MSDN link has more information on format strings.Code:[FONT=Courier New]Print([B]String.Format([/B]"ATR at Entry is: [B]{0:0.00}[/B]"[B],[/B] _atr[0][B])[/B]);[/FONT]
Jessica P.NinjaTrader Customer Service
Comment
-
Originally posted by JBU1314 View PostChelsea, I am trying to implement your suggestion but cant seem to make much progress. Here my code:
I want to round to 2 decimals with date / time /etc. I have shortcut i use:
private void P(string msg)
{
Print(Time[0].ToShortDateString() + " " + Time[0].ToShortTimeString() + ":" + msg);
}
So a sample message I want to round is the current ATR level at entry:
P("ATR at Entry is:" + _atr[0]);
Where would I implement the rounding command? I tried everything and there is no example in the help guide.
ThanksCode:P("ATR at Entry is: " + RoundToTickSize(_atr[0]));Last edited by koganam; 01-27-2017, 12:34 PM.
Comment
-
To clarify JBU1314, koganam is giving instructions on how to round the actual value to the nearest tick, and that advice can be combined with mine. I am not actually affecting the value; rather, my advice affects how the data is displayed.
If you would like to display data to the nearest tick rounded to 2 decimal places, that is
Code:[FONT=Courier New]Print(String.Format("ATR at Entry is: {0:0.00}", RoundToTickSize(_atr[0])));[/FONT]Jessica P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
58 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
133 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment