Skip to content
All library documents

Using Reduced-Precision Float16 and Float8 ONNX Models in MQL5

Article MQL5 articles

Summary

The article describes MQL5 support for ONNX models that use reduced-precision floating-point types. It outlines FP16 and BFLOAT16 alongside several FP8 encodings, and explains converting arrays between these formats and standard float or double values. Cast-operator examples illustrate how model inputs and outputs with nonstandard types can be handled.

An ESRGAN image upscaling example compares a float32 model with a float16 version. The article reports that the converted model file is half the size and that the image output appeared visually similar, with only small code changes needed for conversion. This is a machine-learning implementation example rather than a trading model benchmark: the demonstrated quality comparison concerns images, and the text cautions that financial analysis may require the highest possible precision. It does not establish the effect of reduced precision on trading predictions or execution results.

Key ideas

  • ONNX models can use FP16, BFLOAT16, and several FP8 encodings.
  • MQL5 conversion functions translate arrays between reduced-precision and standard floating-point formats.
  • Input and output buffers must match the model’s declared data types.
  • The ESRGAN example reports a smaller float16 model with visually similar image quality.
  • Image results do not establish that reduced precision is suitable for financial predictions.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.