Put the following into your code
And then everywhere in your code where you would want to use Print() to output something for debugging purposes call log() instead.
Download DebugView from microsoft and start it while you are debugging and you will see the output nicely printed into this window from top to bottom and not from bottom to top and not slow and delayed like in the metatrader log viewer. You can also set filters to view only certain messages and you can set the log window to alway stay on top.
log() takes more than one argument so that you can use it like this:
The messages will be nicely formatted with a " " between every argument and each log message will have a timestamp and the name of the mql4 file and the symbol where it is running on.
Inserted Code
#import "kernel32.dll" void OutputDebugStringA(string msg); #import /** * send information to OutputDebugString() to be viewed and logged * by SysInternals DebugView (free download from microsoft) * This is ideal for debugging as an alternative to Print(). * The function will take up to 8 string (or numeric) arguments * to be concatenated into one debug message. */ void log( string s1, string s2="", string s3="", string s4="", string s5="", string s6="", string s7="", string s8="" ){ string out = StringTrimRight(StringConcatenate( WindowExpertName(), ".mq4 ", Symbol(), " ", s1, " ", s2, " ", s3, " ", s4, " ", s5, " ", s6, " ", s7, " ", s8 )); OutputDebugStringA(out); }
Download DebugView from microsoft and start it while you are debugging and you will see the output nicely printed into this window from top to bottom and not from bottom to top and not slow and delayed like in the metatrader log viewer. You can also set filters to view only certain messages and you can set the log window to alway stay on top.
log() takes more than one argument so that you can use it like this:
Inserted Code
log("entered start function"); log("new bar detected"); log("stoch values", main, main_prev, signal, signal_prev); log("buying", lots, stop, target);