SendNotification() throws "function is not allowed for call"

 

I use the SendNotification() function a couple of times within my code but it throws the error "function is not allowed for call" at only one place within the code. The function throws this error in a function which I use to detect a new day. I new day could start before the actual trading time allowed by the broker. Might this cause the error?

Print("ERR: ", _LastError);
SendNotification("Test");
Print("ERR: ", _LastError);

LastError befure function call is "0" and after SendNotification call it is "4014" -> "Function is not allowed for call".

I am currently testing in strategy tester so function is not working there but at least should not throw this error. 

 
Have you reset _LastError  with ResetLastError()?
 
Don't look at GLE/LE unless you have an error.
SendNotification("Test");
Print("ERR: ", _LastError);
Check your return codes, and report your errors (including market prices and your variables).
if( !SendNotification("Test") ) Print("ERR: ", _LastError);
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
 

@William Roeder thanks for your comment for to improve coding. I wouldn't normally code like that it was just for quick testing purposes.

Print("------------------------\n");     

ResetLastError();
if( !SendNotification("Test") ) Print("ERR: ", _LastError);

DebugBreak();
2022.10.22 10:01:29.348 2016.09.01 13:30:00   ------------------------
2022.10.22 10:01:29.348 2016.09.01 13:30:00   
2022.10.22 10:01:29.348 2016.09.01 13:30:00   ERR: 4014
From SendNotification documentation:
Return Value

true if a notification has been successfully sent from the terminal; in case of failure returns false. When checking after a failed push of notification, GetLastError () may return one of the following errors:

4515ERR_NOTIFICATION_SEND_FAILED,
4516ERR_NOTIFICATION_WRONG_PARAMETER,
4517ERR_NOTIFICATION_WRONG_SETTINGS,
4518ERR_NOTIFICATION_TOO_FREQUENT.


Note

Strict use restrictions are set for the SendNotification() function: no more than 2 calls per second and not more than 10 calls per minute. Monitoring the frequency of use is dynamic. The function can be disabled in case of the restriction violation.

SendNotification() function does not work in the Strategy Tester.

I checked the documentation again, and since the function in which the SendNotification's error is produced is only called once per day. As said, the function is also called a couple more times when e.g. new trade is opened, trade is closed. I trade on D1 candles and per day only 1 trade is opened or closed so that the function is not called very often.

 
MartinaR #: I wouldn't normally code like that it was just for quick testing purposes. I checked the documentation again, and since the function in which the SendNotification's error is produced is only called once per day. As said, the function is also called a couple more times when e.g. new trade is opened, trade is closed. I trade on D1 candles and per day only 1 trade is opened or closed so that the function is not called very often.
  1. Is this happening on your own PC or on a VPS (and is it 3rd party or MQL5 VPS service)?
  2. Did you correctly setup the MetaQuote ID in the Options and run the "Test" to see if it is working correctly?
  3. Is the code running on a live chart or is this in the Strategy Tester?
  4. In which event handler is this being run? Are you perhaps calling it in the OnDeinit() handler?
  5. Besides the error code in the Experts log, are there any accompanying messages in the Journal log?
  6. What build of MT5 are you using?
 
Maybe you are better off if you send emails - these you can send as many times as your provider allows.
 
Fernando Carreiro #:
  1. Is this happening on your own PC or on a VPS (and is it 3rd party or MQL5 VPS service)?
  2. Did you correctly setup the MetaQuote ID in the Options and run the "Test" to see if it is working correctly?
  3. Is the code running on a live chart or is this in the Strategy Tester?
  4. In which event handler is this being run? Are you perhaps calling it in the OnDeinit() handler?
  5. Besides the error code in the Experts log, are there any accompanying messages in the Journal log?
  6. What build of MT5 are you using?

1. Own PC

2. Yes that is working. I use SendNotification a couple more times at different positions in the code and there it does not throw any error

3. it is Stratey Tester. I know that the function as well as SendMail are not working there but it also should not throw any error

4. it is in a function and that function is called in the OnTick() function but there in a function which is called only once a new day has started

5. No, there aren't

6. Version 5.00 build 3446 - 24 Sep 2022


I stopped working on my project for about 3 months and this was the last thing I implemented and back then it did not throw any errors. So it really might depend on changes in the new version

 
Carl Schreiber #:
Maybe you are better off if you send emails - these you can send as many times as your provider allows.

Last solution yes but as commented above, 3 month ago it was still working and I am wondering why it is working in the other functions but not there?

 
MartinaR #:

1. Own PC

2. Yes that is working. I use SendNotification a couple more times at different positions in the code and there it does not throw any error

3. it is Stratey Tester. I know that the function as well as SendMail are not working there but it also should not throw any error

4. it is in a function and that function is called in the OnTick() function but there in a function which is called only once a new day has started

5. No, there aren't

6. Version 5.00 build 3446 - 24 Sep 2022

I stopped working on my project for about 3 months and this was the last thing I implemented and back then it did not throw any errors. So it really might depend on changes in the new version

3. It clearly states in the documentation and you even quoted that it doesn't work in the Strategy Tester. It may have not thrown an error in older builds but in later builds that has been the error given for many of the network and communications functions not allowed in the strategy tester.

 
Fernando Carreiro #:

3. It clearly states in the documentation and you even quoted that it doesn't work in the Strategy Tester. It may have not thrown an error in older builds but in later builds that has been the error given for many of the network and communications functions not allowed in the strategy tester.

OK that might make sense. It's about 3-4 months between and maybe they changed it during that time. Just wondering why it only affects this one and not the other SendNotifications. I mean either all throw an error now or none of them? 

Reason: