SetFPCompareAccuracy (Reserved Word)

image\trumpet2.gif Disclaimer

SetFPCompareAccuracy will allow you to override the default precision tolerance value, allowing for a lower or higher tolerance when comparing two floating point values to be equal.

Two floating point values will be considered equal if ”abs(Value1 - Value2) <= ε” where ε is the tolerance value.   The scope of this function will be limited to the Indicator, Strategy, or Function in which it was called.

Versions of TradeStation prior to 7.0 used 4-byte single precision floating point values for variables and a less precise tolerance, approximately 5.0e-6, when comparing two variables for equality.  Starting with Version 7.0 EasyLanguage uses 8-byte double precision floating point values and a very high tolerance of 2.2204460492503131e-016.  This difference in tolerance checking may cause indicator values between version 7.0 and prior versions to be slightly different.  Specifically, two values that were considered equal in versions prior to 7.0 are no longer considered equal in version 7.0.  In order to address this issue we have changed the default tolerance value to 2.2204460492503131e-012.

Usage

SetFPCompareAccuracy(iTolerance)

Return 

None

Inputs

iTolerance is an integer constant and may be one of the following values:

These are the EasyLanguage constants and their values to pass into SetFPCompareAccuracy, they are defined as follows:  

0 = fpcVeryLowAccuracy  -  tolerance to: 2.2204460492503131e-08

1 = fpcLowAccuracy -  tolerance to: 2.2204460492503131e-010

2 = fpcMedAccuracy - tolerance to: 2.2204460492503131e-012 (this is the default value)

3 = fpcHighAccuracy - tolerance to: 2.2204460492503131e-014

4 = fpcVeryHighAccuracy - tolerance to: 2.2204460492503131e-016

5 = fpcExact - tolerance to: 0.0

Example

Set floating point accuracy to very high  tolerance accuracy:

SetFPCompareAccuracy(fpcVeryHighAccuracy );