Alerts and Warnings when running MT4 tester

 

I can not get Alert or PlaySound working when running my EA code in tester.

Print command does work in Journal, but with lag and I prefer popup alert to troubleshoot my code.

Any suggestion what should I try?


if(a1>1)                                                      //fix: when there are more than one sell order
{
Print("There are too many Sell orders ",a1);
Alert("There are too many Sell orders ",a1);
PlaySound("tick.wav");
}
 
elanin:

I can not get Alert or PlaySound working when running my EA code in tester.

Print command does work in Journal, but with lag and I prefer popup alert to troubleshoot my code.

Any suggestion what should I try?


You should try reading this:  Testing Features and Limits in MetaTrader 4

And you could consider using Comment()  or my CommentLab() code.

 
RaptorUK: And you could consider using Comment()  or my CommentLab() code.
Or DBGview and my Log() function or https://www.mql5.com/en/forum/142787
 
WHRoeder:
Or DBGview and my Log() function
Did you mean this ?  https://www.mql5.com/en/forum/142787
 

The offered solutions are way too complicated. Things are more simple:

#import "user32.dll"
   int  MessageBoxA(int hWnd, string lpText, string lpCaption, int style);
#import "winmm.dll"
   bool PlaySoundA(string lpSound, int hMod, int fSound);
#import

#define MB_OK         0x00000000
#define SND_ASYNC           0x01       // play asynchronously
#define SND_FILENAME  0x00020000       // parameter is a file name


/**
 * Force playback of a sound even if not supported by MT4.
 *
 * @param  string soundfile
 */
void ForceSound(string soundfile) {
   if (!IsTesting()) PlaySound(soundfile);
   else              PlaySoundA(StringConcatenate(TerminalPath(), "\\sounds\\", soundfile), NULL, SND_FILENAME|SND_ASYNC);
}


/**
 * Force an alert even if not supported by MT4.
 *
 * @param  string message
 */
void ForceAlert(string message) {
   if (!IsTesting()) {
      Alert(message);
   }
   else {
      ForceSound("alert.wav");
      MessageBoxA(NULL, message, "Alert", MB_OK);
   }
}
 
paulepanke:

The offered solutions are way too complicated. Things are more simple:


Comment()  is too complicated ? ?
 
elanin: ... I prefer popup alert to troubleshoot my code.
 
RaptorUK: Comment()  is too complicated ??
Yes, too complicated as a popup replacement. Furthermore, Comment() doesn't work at all if VisualMode=Off.
Reason: