Support Board
Date/Time: Tue, 24 Dec 2024 02:56:03 +0000
sc.RoundToTickSize function
View Count: 1366
[2015-10-24 20:50:32] |
Johnny - Posts: 99 |
I have created subgraphs in my study that use this function in order to round numbers to the instrument ticksize value. When the value format equals the ticksize everything is fine, however when I increase the value format the numbers don't remain rounded to the ticksize value. So, for example with a value format of 0.0000001, 45.24 becomes 45.2399979. From my understanding when I increase the value format beyond ticksize the numbers must be displayed with more decimal points but remain rounded nonetheless. In this case I was expecting the number displayed to be 45.2400000. Does that mean that the function doesn't work properly?
|
[2015-10-25 00:08:40] |
Sierra Chart Engineering - Posts: 104368 |
This is normal due to floating-point error: http://www.sierrachart.com/index.php?page=doc/doc_StudiesSystemsAlerts.php#ImprecisionOfFloatingPointNumbers Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2015-11-02 16:46:48] |
Johnny - Posts: 99 |
I'm trying to round floating-point numbers to only two decimal places and discard all the remaining in order to use them in internal study calculations. I've used the round function in the following way: round(Number * 100) / 100. But the division by 100 makes all the other decimal places appear again. Is there a way to achieve this?
|
[2015-11-02 17:59:26] |
Sierra Chart Engineering - Posts: 104368 |
You need to use this function: sc.RoundToTickSize(float Value, float TickSize) Specify the increment with TickSize. For example .01. This does does not solve a small degree of floating-point error. This will always persist. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2015-11-02 19:01:30] |
Johnny - Posts: 99 |
I'm aware of the sc.RoundToTickSize function but it's not enough. I'm comparing the VWAP values with the POC and OHLC values and I want to completely eliminate the floating-point error for ultimate precision. So, there's no solution for this?
|
[2015-11-02 19:14:12] |
Sierra Chart Engineering - Posts: 104368 |
In this case you need to use this function: https://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scFormattedEvaluate Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: