maximum length of string input for mt4

 

Mt4 tester string input field seems to be able to handle 511 characters and possibly more if you input the string into the EA properties window press ok (you'd have to do this each time you load a string.

This is the only link I could find, but it is from 2007.  One of the posts say 255 character limit.  https://www.mql5.com/en/forum/46439

I have a situation where I tried a long string (900 characters) and it was almost as if the input field was ignored.  I reduced it to 150 characters and then the input was read just fine.  I increased it to 247 characters and again it was ok.  I increased it to 287 characters and then the input was ignored (as if it was blank).

How do I get EA to accept an input greater than 255 characters?  We were putting kernel.dll to read the long string from a text file.  But we want to do it without using any external dlls (only using mql functions).

Actually, the long string should be read from the EA properties input field if possible.

 

Well, it is really rare to input more than 255 characters on start, though I can imagine some file paths can exceed it. The other part - using the kermel.dll - I did not get. What is wrong with the built-in file functions that you need to substitute them?

 
4evermaat:

Mt4 tester string input field seems to be able to handle 511 characters and possibly more if you input the string into the EA properties window press ok (you'd have to do this each time you load a string.

This is the only link I could find, but it is from 2007.  One of the posts say 255 character limit.  https://www.mql5.com/en/forum/46439

I have a situation where I tried a long string (900 characters) and it was almost as if the input field was ignored.  I reduced it to 150 characters and then the input was read just fine.  I increased it to 247 characters and again it was ok.  I increased it to 287 characters and then the input was ignored (as if it was blank).

How do I get EA to accept an input greater than 255 characters?  We were putting kernel.dll to read the long string from a text file.  But we want to do it without using any external dlls (only using mql functions).

Actually, the long string should be read from the EA properties input field if possible.

Use several inputs. Maybe you can explain why you need such a long string ?
 
zirkoner:
Use several inputs. Maybe you can explain why you need such a long string ?

For example, i may need to manually input multiple exact date/times in which to tell the EA not to trade or perform a function:  e.g. "2016.03.09 12:30 - 2016.03.10 06:00 S, 2016.03.10 10:00 - 2016.09.10 14:00 S, etc"  S is an additional switch used to implement proprietary function.

I already use a day of the week noTrade string input which strings are much smaller because it is usually the same times every week.  But specific dates in the future (or past for backtest)

Another example would be to read multiple news announcement text for keywords.

Ovo:

Well, it is really rare to input more than 255 characters on start, though I can imagine some file paths can exceed it. The other part - using the kermel.dll - I did not get. What is wrong with the built-in file functions that you need to substitute them?

mt4 seems to be limited to reading/writing text to the [data folder]\mql4\files (or [data folder]\tester\files when using tester).  So to read a .set file from a specific location (usually mql4\presets\ or \tester) that contained a very long string, a windows dll (kernel32.dll I think) was needed.  Then we could have a 5000 string or longer no problem.

 
4evermaat:

... 

mt4 seems to be limited to reading/writing text to the [data folder]\mql4\files (or [data folder]\tester\files when using tester).  So to read a .set file from a specific location (usually mql4\presets\ or \tester) that contained a very long string, a windows dll (kernel32.dll I think) was needed.  Then we could have a 5000 string or longer no problem.

The kernel32 works fine, but you are losing some security - MT4 internal file handling closes handles automatically on script failure/exit. If your location is fixed to a folder, you may consider using a symbolic link in MQL4/files.
 
Ovo:
The kernel32 works fine, but you are losing some security - MT4 internal file handling closes handles automatically on script failure/exit. If your location is fixed to a folder, you may consider using a symbolic link in MQL4/files.

The long string reader was actually designed not only for launching EA, but also when terminal is restarted.  A separate function handles recovery quite well (EA or terminal restart), so that the EA can resume functioning where it left off.

Are you saying that the handles are not closed automatically when script ends or fails?

 
4evermaat:

For example, i may need to manually input multiple exact date/times in which to tell the EA not to trade or perform a function:  e.g. "2016.03.09 12:30 - 2016.03.10 06:00 S, 2016.03.10 10:00 - 2016.09.10 14:00 S, etc"  S is an additional switch used to implement proprietary function.

I already use a day of the week noTrade string input which strings are much smaller because it is usually the same times every week.  But specific dates in the future (or past for backtest)

Another example would be to read multiple news announcement text for keywords.

mt4 seems to be limited to reading/writing text to the [data folder]\mql4\files (or [data folder]\tester\files when using tester).  So to read a .set file from a specific location (usually mql4\presets\ or \tester) that contained a very long string, a windows dll (kernel32.dll I think) was needed.  Then we could have a 5000 string or longer no problem.

I see thanks. Reading a file is effectively the best option.
Reason: