Is it possible to write in different styles to a .txt file?
I don´t have a clue where i could add the style input.
The total code is a bit more compilicated with for and if and so on, so i just wrote down a simple version.
It would be very nice if someone could help me out here, I already tried a couple if things but i was just producing errors.
And i couldn't find another topic like this.
Thank you in advance!
Per definition of plain text format "TXT" files can't show any kind of formatting. However, you can output HTML code into a plain text file with ".html" extension for later rendering the text in a web browser. I recommend you have a look at the statement.htm file present in the "Templates" folder of the metatrader directory.
 a quick search in Google returned with interesting article https://www.mql5.com/en/articles/1544
Thank you for your answer!
So later rendering is the only option? I wanted to avoid to highlight things by hand.
I already put the ending .xls behind, so it will be opened by Excel but the missing format in some lines is still anyoing.
I hoped for some format commands which i could simply add to my lines.
Never the less, thank you anyway!
Plain text is always going to be Plain text no matter which application you use to open it.
If you want "formatted" text, use the various formats available, such as HTML as already mentioned, or Rich Text Format with a ".rtf" extension which can be open Windows Write or with Microsoft Word.
For more advanced sophisticated formatting, especially for Microsoft Excel, you can also Office Open XML which will allow you to layout your spreadsheet in great detail.
True, but i would like to change the format in the code, so i dont have to change it later on my own every time.
But that is exactly what was stated! From within your EA code, you generate or output in whatever text format you want, using one of the conventions stated, be it HTML, RTF or OOXML, or any other you choose.
For example you could output this in HTML:
// Untested, uncompiled code, just to serve as example
string strFile = "output.html";
int hndFile = FileOpen( strFile, FILE_TXT | FILE_READ | FILE_WRITE );
if( hndFile != INVALID_HANDLE )
FileWrite( hndFile, "<html><body>" );
for( int i = 0; i < 10; i++ )
FileWrite( hndFile, "<p>Line ", i, ": This is text with <b>bold</b> and <i>italics</i></p>" );
FileWrite( hndFile, "</body></html>" );
FileClose( hndFile );
Ohh, sorry seems that i misunderstood you.
Thank you very much!!
That helps a lot!!!
Adding to the previous answers . . . .
Some editors can do syntax highlighting based upon the file type. This is much like the syntax highlighting that Metaeditor does for .mqh or .mq5 files.
For example, my log files are simple text files (extension .txt). I created a template for my editor (VIM) that darkens any line with INFO, makes all date/time green, all numbers light blue, trade direction (BUY) in dark blue and (SELL) in dark red, etc.
I wouldn't say this is trivial to do, but it keeps your log files clean (no html markup).
Thats also a nice idea!
Thank you! :)