Author: Kalenzo
Alert_MA

This script is designed as a specialized monitoring tool for the MetaTrader platform. Its primary purpose is to provide real-time notifications when the current market price enters a specific "zone" around a Moving Average—a common technical analysis tool used by traders to identify trends.

How the Logic Works

The script operates by constantly tracking two main components:

1. The Moving Average Baseline The tool calculates a Moving Average based on several customizable settings provided by the user, including the time period (how many past candles to analyze), the calculation method (how it smooths out price data), and the specific price type used for the calculation. This serves as the "center line" for the tool's logic.

2. The Detection Zone Unlike standard indicators that only trigger when a price crosses a line, this script defines a small "buffer zone" or range around that Moving Average. You can define exactly how wide this range should be.

The Alert Trigger

The script continuously monitors the current "Bid" price (the selling price of the market). It triggers an immediate alert if the current price falls within the specified range above or below the Moving Average.

In practical terms, instead of waiting for a precise cross-over point—which can sometimes be missed due to rapid market fluctuations—this tool alerts you whenever the price is "hovering" or interacting closely with the moving average. When this condition is met, it generates a pop-up alert on your screen, notifying you of the specific currency pair and the current price at that exact moment.

Indicators Used
Moving average indicator
Miscellaneous
It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
Alert_MA
//+------------------------------------------------------------------+
//|                                                     Alert_MA.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
extern int range = 1;
extern int ma_period = 55;
extern int ma_shift = 0;
extern int ma_method = MODE_EMA;
extern int applied_price = PRICE_CLOSE;
 
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    
//----bb
   double ma = iMA(Symbol(),0,ma_period,ma_shift,ma_method,applied_price,0);
   
   if( (Bid <= ma+(range*Point)) && (Bid >= ma-(range*Point)))
   Alert(Symbol()+" "+ma_period+" Moving Average range reached at ",Bid);
    
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments