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 Mindset, 04-21-2026, 06:46 AM
|
0 responses
88 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
135 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
68 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
119 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
69 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment