The ROUND function in ProBuilder language is a mathematical function used to round a numerical value to the nearest whole number or to a specified number of decimal places. This function is particularly useful in financial and trading algorithms where precise value adjustments are needed for analysis and decision-making.
Definition and Purpose:
The ROUND function modifies a numerical value, either by rounding it to the nearest whole number or to a specified number of decimal places. This helps in normalizing data or setting precision for further calculations.
ROUND(a, digits)
Here, a is the number to be rounded. The digits parameter is optional and specifies the number of decimal places to which the number a should be rounded. If digits is omitted, the number is rounded to the nearest whole number.
To demonstrate the ROUND function, consider the following example where we calculate the Rate of Change (ROC) of the closing prices over the last 10 periods and then round the result:
i1 = ROC[10](close)
roundedROCvalue = ROUND(i1)
RETURN i1, roundedROCvalue
In this example, if i1 equals 9.60, the roundedROCvalue would be 10.
This function is essential in data preparation and analysis within the ProBuilder environment, ensuring that numerical data conforms to desired precision levels for accurate and effective analysis.