ref: https://ninjatrader.com/support/help...toticksize.htm
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
Double difference strange results
Collapse
X
-
Originally posted by ninjo View Post
ref: https://ninjatrader.com/support/help...toticksize.htm
- Likes 1
-
Hello ninjo,
Thanks for your post.
This mathematical behavior is expected with floating point arithmetic. We have some various tips on working with floating point arithmetic in our Tip page below.
Floating point math - https://ninjatrader.com/support/help...arithmetic.htm
Rounding the result to your expectation is viable. For being able to identify the number of digits needed for the rounding precision, you could follow an approach similar to those suggested in the publicly available resource below to get the number of significant digits in TickSize.
Finding the number of places after the decimal point of a number - https://stackoverflow.com/questions/...nt-of-a-double
Please let us know if we can be of further assistance.
Leave a comment:
-
I solved it with Math.Round function:
Code:double theDif = Math.Round( 0.709 - 0.7091, 4);
The problem is that I want to claculate the number of ticks between two chart prices.
Code:Math.Round( 0.709 - 0.7091, 4) / TickSize
In this case the price have 4 decimals, but how could I set for all markets??
Thank you
Leave a comment:
-
Double difference strange results
Hello,
I am trying to obtain the difference between two doubles and NT8 return stranges results:
Code:double theDif = 0.709 - 0.7091; Print("theDif--> "+ theDif);
And the Output result is:
theDif--> -9,9999999999989E-05
The result would be -0,0001
What I am doing bad? Thank you.
Last edited by ninjo; 03-11-2019, 10:44 AM.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by r68cervera, Today, 05:29 AM
|
0 responses
2 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
3 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
35 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,239 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
6 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Leave a comment: