Hi
how many characters a string can have in mql5?
EDIT: The actual limit is not below 4800, as I was remembering wrong, it is actually 16381 chars that printf() or Print() function will print in a single call to expert-journal.
Proof, see below.
#property script_show_inputs string longText; void OnStart() { appentToText ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); appentToText ("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); appentToText ("ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"); appentToText ("ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"); appentToText ("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); appentToText ("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); appentToText ("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); appentToText ("jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); appentToText ("==================================================================="); Print("longText lengh is: " + longText.Length()); Print(longText); } void appentToText ( string txt) { string temp; StringConcatenate(temp, longText , txt); longText = temp; }
I have written this code. It prints only 603 characters on terminal output. (longText lengh is: 603)
why it doesn't print all characters?
Why are you thinking it's below 4800 ?
I have here a string of 65,966 characters. It's from one of my project, I didn't check what the limit could be.
Why are you thinking it's below 4800 ?
I have here a string of 65,966 characters. It's from one of my project, I didn't check what the limit could be.
Why are you thinking it's below 4800 ?
I have here a string of 65,966 characters. It's from one of my project, I didn't check what the limit could be.
I have tested the limit of printf and Print function, here is the script to reproduce.
Result: Max printable string-len using either is 16382 characters in a string.
static string test = NULL; //+------------------------------------------------------------------+ //| Service program start function | //+------------------------------------------------------------------+ void OnStart() { // printf string limit is 16382 chars // Print string limit is 16382 chars. StringInit(test, 16350, 0x0040); int alpha = StringLen(test); while( (StringLen(test) == alpha) && (alpha < 16390) && (!_StopFlag) ) { test += CharToString((char)((alpha%(96 - 65)) + 65)); Print(test); Print("Size: ", StringLen(test)); alpha++; } StringInit(test, 16350, 0x0040); alpha = StringLen(test); while( (StringLen(test) == alpha) && (alpha < 16390) && (!_StopFlag) ) { test += CharToString((char)((alpha%(96 - 65)) + 65)); printf("%s", test); printf("Size: %i", StringLen(test)); alpha++; } return; }
I have tested the limit of printf and Print function, here is the script to reproduce.
Result: Max printable string-len using either is 16381 characters in a string.
Ok but the topic was not about printf or Print.
I am getting a limit of 16364 (I moved the start of the line at the end to better show it).

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
how many characters a string can have in mql5?