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
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.
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 :
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 judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
53 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
32 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
4 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
6 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment