FXTAA Русская версия

Forex indicator alerter: sound and push alerts for levels

You marked the levels that matter, then spent the day staring at the chart waiting for price to arrive. MT4 can do the waiting for you — in three different ways, each with its own failure mode.

Updated: 2026-09-22

There are three separate mechanisms in MetaTrader 4 that people lump together as "alerts". They behave differently, and picking the wrong one is the usual reason a trader says alerts "do not work".

1. The built-in Alerts tab

Open the Terminal window with Ctrl+T and switch to the Alerts tab. Right-click inside it and choose Create. You get a dialog where you set a symbol, a condition (Bid >, Bid <, Ask >, Ask <), a value, and an action — play a sound, send an email, or run a file.

This is the simplest option and it needs no code. Its limitation is that the alert is tied to a number you typed, not to an object on the chart. Move your horizontal line and the alert stays where it was.

An alert fires on an incoming tick. Over the weekend there are no ticks, so an alert cannot fire, and a Monday gap straight through your level produces no notification at all — price was never quoted there.

2. Sound alerts

Sounds are controlled in Tools → Options → Events. Every event has a .wav file attached, and you can replace them with your own — MT4 looks in the Sounds folder of the terminal's data directory. The data directory is not necessarily where you installed the program; File → Open Data Folder takes you to the right place.

A practical detail: if the terminal is minimised to the tray and Windows has muted the application, you will see the alert in the log and hear nothing. Check the per-application volume mixer before blaming MT4.

3. Push notifications to your phone

This is the only mechanism that reaches you away from the desk. Install the MetaTrader 4 mobile app, open its settings and find the MetaQuotes ID — an eight-character code. In the desktop terminal go to Tools → Options → Notifications, tick Enable Push Notifications and paste that ID.

A level alerter that follows your lines

The useful behaviour — "tell me when price crosses any horizontal line I drew" — needs a few lines of MQL4. The idea is to walk the chart objects on every tick, keep only the horizontal lines, and compare the previous Bid with the current one.

// LevelAlerter.mq4 — alerts when Bid crosses any horizontal line
#property indicator_chart_window

input bool  UseSound = true;
input bool  UsePush  = false;
input int   CooldownSeconds = 60;

double   prevBid = 0;
datetime lastFire = 0;

int OnInit() { prevBid = Bid; return(INIT_SUCCEEDED); }

int OnCalculate(const int rates_total, const int prev_calculated,
                const datetime &time[], const double &open[],
                const double &high[], const double &low[],
                const double &close[], const long &tick_volume[],
                const long &volume[], const int &spread[])
{
   if(prevBid == 0) { prevBid = Bid; return(rates_total); }

   for(int i = ObjectsTotal() - 1; i >= 0; i--)
   {
      string name = ObjectName(i);
      if(ObjectType(name) != OBJ_HLINE) continue;

      double level = ObjectGet(name, OBJPROP_PRICE1);

      // crossed in either direction between the previous tick and this one
      bool crossed = (prevBid < level && Bid >= level) ||
                     (prevBid > level && Bid <= level);

      if(crossed && TimeCurrent() - lastFire >= CooldownSeconds)
      {
         string msg = StringFormat("%s %s crossed %s (%s)",
                      Symbol(), DoubleToString(Bid, Digits),
                      DoubleToString(level, Digits), name);

         if(UseSound) Alert(msg);            // Alert() also writes to the Alerts tab
         if(UsePush)  SendNotification(msg); // needs MetaQuotes ID in Options
         lastFire = TimeCurrent();
      }
   }
   prevBid = Bid;
   return(rates_total);
}

Compile it in MetaEditor (F7), then drag it onto a chart from the Navigator. Draw horizontal lines as usual — the indicator picks them up automatically because it reads objects, not a saved list.

Why the cooldown matters

Without CooldownSeconds the alerter is unusable. Price does not cross a level once; it oscillates around it, and every oscillation is a crossing. A quiet level can generate forty alerts in a minute and train you to ignore the sound entirely.

Sixty seconds is a reasonable default. If you trade levels on M1 you will want less; if you watch daily levels, several minutes is better.

Things that will bite you

SymptomCause
Alert fires on the wrong chartThe indicator runs per chart. Attaching it to EURUSD does not watch GBPUSD lines.
Nothing fires after a restartprevBid starts at zero and the first tick only initialises it. This is intentional — otherwise every line below price alerts at once on startup.
Push works, sound does notAlert() respects Tools → Options → Events. If Enable events is unticked, the dialog appears silently.
Alerts stop overnightThe terminal went to sleep with the machine. Disable sleep, or run the terminal on a VPS.

Testing without risking anything

Alert logic is worth testing on a demo account for a week before you rely on it, because most of the failure modes above only show up in live tick flow. Push notifications in particular depend on the broker's server delivering ticks steadily — a server that drops connections at rollover produces gaps in alerting that you will not see in the strategy tester.

If you are picking a broker to run this on, the practical criteria are a stable MT4 server, deep tick history and no artificial limits on custom indicators. One commonly used option is reviewed here: RoboForex broker review.