Login Page - Create Account

Support Board


Date/Time: Tue, 07 May 2024 20:40:30 +0000



Prices incorrect for Open, High, Low Close

View Count: 874

[2020-10-30 03:59:59]
like2trade - Posts: 112
Hi,

I displayed the following prices for Silver futures SIZ20 in the message log. I am using these numbers in ACSIL logic and it is not working because the Silver prices should be up to only 3 digits after the decimal point. The following numbers contain a 1 and 2 as the last digits which is not supposed to happen. Do you know what the problem is?

O: 23.370001, H: 23.370001, L: 23.365002, C: 23.370001

This is the code that produced this in the message log.

MessageText.Format("O: %f, H: %f, L: %f, C: %f", sc.Open[sc.Index - 1], sc.High[sc.Index - 1], sc.Low[sc.Index - 1], sc.Close[sc.Index - 1]);
sc.AddMessageToLog(MessageText, 0);

Thank you.
[2020-10-30 08:40:19]
Ackin - Posts: 1865
Try in your code change

%f


to

%.3f

Date Time Of Last Edit: 2020-10-30 08:42:50
[2020-10-30 08:57:37]
like2trade - Posts: 112
Hi Ackin,

I tried your recommendation and now the output is:

O: 23.3700008392, H: 23.3800010681, L: 23.3700008392, C: 23.3800010681

The problem for me is not really the output, but the fact that there is non zero digits after the 3rd decimal place. I am comparing sc.Low[sc.Index] and sc.ChartTradingOrderPrice and it is not giving me the expected result. I am having to truncate sc.Low[sc.Index] to 3 decimal places in order for my logic to work. For example sc.ChartTradingOrderPrice = 23.365000 but sc.Low[sc.Index] = 23.365001. This should not be happening.

Thank you.
[2020-10-30 09:06:19]
Ackin - Posts: 1865
Hi,

I don't know, it occurs to me that this is not important if the main values are accurate. Try using the function to round to the nearest tick (round to tick) and then check the main swings, for example with another platform or online chart data. I think it will be the same as what you see after rounding here.
[2020-10-30 09:14:59]
like2trade - Posts: 112
Of course I could program a work around, but the point is that this should not be happening. I am hoping that Sierra Engineering can shed some light on this.

Thanks.
[2020-10-30 10:22:59]
Sierra Chart Engineering - Posts: 104368
This information is written in relation to Spreadsheets but also applies here as well:
Using the Spreadsheet Study: Imprecision of Floating-Point Numbers and Comparisons
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
[2020-10-30 15:55:42]
like2trade - Posts: 112
Thank you for the link Sierra Engineering. What is the best way to handle this in ACSIL? Can you please provide an ACSIL example.

Thank you very much.
[2020-10-30 16:19:06]
like2trade - Posts: 112
FYI, I will be using the same study on instruments that have 2, 3, 4, and 5 decimal places. So the solution would have to be generic.

Thanks.
Date Time Of Last Edit: 2020-10-30 16:22:25
[2020-10-30 22:27:57]
User907968 - Posts: 802
sc.FormattedEvaluate()
[2020-10-31 02:01:34]
like2trade - Posts: 112

This worked perfectly. Thank you very much.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account