Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
comparing decimal value
Collapse
X
-
Hello junkone, thanks for writing in.
The Truncate method will remove the decimal portion of the number. You would need to use Math.Round to ensure the values you get are always 5 decimal places long. See this publicly available link :
Try Printing the values you get from rounding the Price and EMA values to see how the comparison will be evaluated.
Please let me know if I can assist any further.Chris L.NinjaTrader Customer Service
Comment
-
Originally posted by s.kinra View PostHello,
Can you give your comparison for indicator values you need so I can give you an example relevant to your requirement.
if (IsFirstTickOfBar)
{
if ((CountIf(() => EMA(Close, 9)[1] > EMA(Close, 20)[1], 20) >= 20) && (CountIf(() => EMA(Close, 20)[1] > SMA(Close, 50)[1], 20) >= 20))
{
}
Comment
-
Hello,
Try this:
Code:if (IsFirstTickOfBar) { if ((CountIf(() => ( Math.Truncate(EMA(Close, 9)[1] * 10000) / 10000 ) > ( Math.Truncate(EMA(Close, 20)[1]* 10000) / 10000 ), 20) >= 20) && (CountIf(() => ( Math.Truncate(EMA(Close, 20)[1]* 10000) / 10000 ) > ( Math.Truncate(SMA(Close, 50)[1]* 10000) / 10000 ), 20) >= 20)) { }
You should Print the values of EMA, SMA etc. to confirm if its truncated to 4 digits & be sure your condition is evaluated as expected. Test this & see if you get the desired results. This will eliminate the 5th or higher decimal place from calculation, so take informed call if you need Truncate or Round.Last edited by s.kinra; 11-16-2020, 09:56 AM.
- Likes 1
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by techgetgame, Today, 11:42 PM
|
0 responses
5 views
0 likes
|
Last Post
by techgetgame
Today, 11:42 PM
|
||
Started by sephichapdson, Today, 11:36 PM
|
0 responses
1 view
0 likes
|
Last Post Today, 11:36 PM | ||
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,612 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
Comment