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
If statement and comparing double equality
Collapse
X
-
If statement and comparing double equality
I have an "if" statement that looks for doubles being equal:
if(Low[1] == LowPivotOne)
where: LowPivotOne is a double
LowPivotOne is set via: LowPivotOne = Low[1];
Essentially this is checking to see if the current Low[1] is equal to the previous low pivot.
Problem is, this method is random. Sometimes it works and other times it doesn't. I've searched on this problem and learned that comparing doubles for equality is problematic. This is because doubles are not stored as precise numbers and will have small offsets.
I've tried Convert.To.Decimal but that started getting out of hand. I had to continually convert more and more variables and it just didn't seem the most elegant solution.
Is there a fairly simple way to compare two doubles for equality in an If statement?
regards,
taddypole...Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Irukandji, Today, 04:58 AM
|
0 responses
2 views
0 likes
|
Last Post
by Irukandji
Today, 04:58 AM
|
||
Started by fitspressoburnfat, Today, 04:25 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 04:25 AM | ||
Started by Skifree, Today, 03:41 AM
|
1 response
4 views
0 likes
|
Last Post
by Skifree
Today, 03:42 AM
|
||
Started by usazencort, Today, 01:16 AM
|
0 responses
1 view
0 likes
|
Last Post
by usazencort
Today, 01:16 AM
|
||
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
604 views
0 likes
|
Last Post Today, 12:32 AM |