allanster

How To Count Decimals

allanster Wizard Updated   
Custom f_nDecimals() function returns precision of decimal numbers of the following forms:
const, input, simple, and series of the following types: float, integer, and string.
Error checking is performed for valid numbers and invalid values return NaN.

NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!
Release Notes:
Revision 1

Added a compact refactored equivalent version of function: f_nDecimals().
Renamed original annotated version of function to: f_nDecimal5().
Added column to matrix table to compare equivalency.
Release Notes:
Cosmetic.
Release Notes:
Revision 2

Implemented a more detailed grid for testing higher precision values. Increased precision of example output values.
Release Notes:
Cosmetic.
Release Notes:
Cosmetic.

lux ex tenebris • deuro mea umbra absens • Telegram: t.me/allanster
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?