Loading…

Email And Push Helper

Alert(), SendNotification(), SendMail() and PlaySound() are each a single line to call. What breaks EAs in production is calling one of them from inside OnTick() with no rate limit: a stuck condition - price stuck at a level, a connection that will not recover - fires the same push notification on every tick until either the phone is unusable or the mail server starts rejecting the account as spam. This header adds a throttle keyed by a string tag. The first call for a tag goes through; any further call for the same tag within a configurable cooldown is silently dropped and the function returns false so the caller can tell the difference. Different tags are tracked independently, so a margin warning and a connection warning never block each other. Push notifications are also quietly capped by the terminal at 255 characters - exceed it and SendNotification simply fails. NotifyPush truncates locally first, so what actually gets sent is visible in the log rather than being a silent server-side rejection. Push and email are both suppressed automatically inside the Strategy Tester. A backtest run over years of history would otherwise attempt to send exactly as many notifications as a live run would over that period, which is never what a backtest actually wants. NotifyAll() fans a single message out to any combination of the four channels behind one throttle key, so "margin call" cannot alert once but push twice because two code paths both happened to call it in the same second. Notes and limitations - SendMail requires an SMTP account configured under Tools -> Options -> Email. SendNotification requires a MetaQuotes ID configured under Tools -> Options -> Notifications. Neither is set up on a fresh install; both simply fail and log an error rather than crashing, so the demo is safe to run immediately. - Throttle state lives in memory only, for the life of the chart. It is not saved to a global variable or a file, so removing and re-attaching the program resets every cooldown. Combine with GlobalVarStore.mqh (also in this catalogue) if a cooldown needs to survive a restart. - NotifyAll's per-channel keys are derived from the group key, not from the message text, so calling it twice with different messages but the same explicit throttleKey will throttle the second call - this is intentional and matches how a single logical event is expected to be de-duplicated.

Script · MT4 · v1.0 · Free

About Email And Push Helper

Email And Push Helper is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Prefix and Throttle seconds. MQL source code included.

Files in the download: NotifyHelper.mqh, NotifyHelper.txt, NotifyHelperDemo.mq4.

Settings

SettingDefaultWhat it does
PrefixDemoEATag prepended to every message
Throttle seconds5Cooldown applied to the throttle demo below

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria