PrintFormat Function
Formats and enters sets of symbols and values in the Expert Advisor log.
Syntax
void PrintFormat(string format_string, ...);
Parameters
format_string [in]: A string containing plain characters and format specifications (starting with '%').... [in]: Values of simple types, separated by commas. Maximum 64 parameters including format_string.Return Value
String (implicitly, as it's printed to log).
Notes
printf() can be used as an alternative.%%[flags][width][.precision][{h | l | ll | I32 | I64}]type#### Format Specification Fields:
flags**: Control output alignment and sign display.-: Left justification.
* +: Always show sign.
* 0: Zero-padding.
* (space): Space before positive signed values.
* #: Alternate output form (e.g., 0x prefix for hex).
width**: Minimum number of output characters. Padded with spaces or zeros based on flags. If *, width is taken from an argument.precision**: Number of digits after decimal point for floating-point types, or minimum digits for integers. Can truncate floating-point values.{h | l | ll | I32 | I64}**: Data size specifiers for integer types.type**: Specifies the output format.c, C: Character.
* d, i: Signed decimal integer.
* u: Unsigned decimal integer.
* o: Unsigned octal integer.
* x, X: Unsigned hexadecimal integer.
* e, E: Scientific notation (double).
* f: Fixed-point notation (double).
* g, G: Compactest of f or e.
* a, A: Hexadecimal floating-point notation.
* s, S: String.Example
// Example demonstrating various format specifiers
string server = AccountInfoString(ACCOUNT_SERVER);
int login = (int)AccountInfoInteger(ACCOUNT_LOGIN);
long leverage = AccountInfoInteger(ACCOUNT_LEVERAGE);PrintFormat("%s %d: leverage = 1:%I64d", server, login, leverage);
double equity = AccountInfoDouble(ACCOUNT_EQUITY);
string currency = AccountInfoString(ACCOUNT_CURRENCY);
PrintFormat("%s %d: account equity = %.2f %s", server, login, equity, currency);
double profit = AccountInfoDouble(ACCOUNT_PROFIT);
PrintFormat("%s %d: current result for open orders = %+.2f %s", server, login, profit, currency);
double point_value = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
string format_string = StringFormat("%%s: point value = %%.%df", _Digits);
PrintFormat(format_string, _Symbol, point_value);
int spread = (int)SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
PrintFormat("%s: current spread in points = %d ", _Symbol, spread);
PrintFormat("DBL_MAX = %.17e", DBL_MAX);
PrintFormat("EMPTY_VALUE = %.17e", EMPTY_VALUE);
PrintFormat("PrintFormat(EMPTY_VALUE) = %e", EMPTY_VALUE);
Print("Print(EMPTY_VALUE) = ", EMPTY_VALUE);