Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 07:08:37 +0000



Post From: convert price to price-in-ticks

[2013-04-25 18:20:12]
onnb - Posts: 661
int Ticks = sc.Close[sc.Index]/sc.TickSize;

That isn't accurate in some cases. When you divide floats like that you will receive values that are close but not exact integer values.
The code above would always round down so if the division comes out to 5999.9999 the result would be 5999. A common method to overcome this this would be:

int Ticks = (int)floor(sc.Close[sc.Index]/sc.TickSize + 0.5);

but its best if the guys at SC deal with these things and provide a good api we all can use ;)