21 May 2021
21 May 2021
struct complex { double real; // Real part double imag; // Imaginary part };The "complex" type can be passed by value as a parameter for MQL5 functions (in contrast to ordinary structures, which are only passed by reference). For functions imported from DLLs, the "complex" type must be passed only by reference.
complex square(complex c) { return(c*c); } void OnStart() { Print(square(1+2i)); // A constant is passed as a parameter } // "(-3,4)" will be output, which is a string representation of the complex numberOnly simple operations are currently available for complex numbers: =, +, -, *, /, +=, -=, *=, /=, ==,!=.