Alert_MA_v3
Download scriptThis script is designed as a specialized alert tool for traders who use Moving Averages to monitor market trends. Instead of creating complex visual shapes or drawings on your chart, its primary purpose is to provide real-time notifications when the market price interacts with a specific moving average level.
How it Works
The logic follows a straightforward three-step process:
1. Defining the Baseline The script calculates a Moving Average (MA) based on settings you choose (such as the number of periods, the type of average like EMA, and the price source). This acts as your "baseline" or reference point for the current market trend.
2. Monitoring the Price Zone Rather than just alerting you when the price touches the line exactly, this script looks for a specific "range." You can define a small buffer zone around the moving average. The logic checks if the current market price (the Bid) is currently hovering within this defined proximity to the moving average.
3. Real-Time Notification Whenever the market price enters that specific zone, the script immediately triggers an alert on your platform. The notification will display:
- The name of the currency pair or asset you are trading.
- The specific Moving Average period being monitored.
- The current live price at the moment the threshold was reached.
Key Benefits for Traders
- Reduced Screen Time: You don't have to constantly watch the chart to see if the price is "hitting" your moving average; the script notifies you automatically.
- Precision Monitoring: By using a customizable range, it ensures you are alerted even if the price fluctuates slightly around the line rather than just crossing it perfectly.
- Customizable Parameters: You can easily adjust the period length and type of moving average to match your specific trading strategy.
//+------------------------------------------------------------------+
//| 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);
}
//+------------------------------------------------------------------+ èÇ '5 3 b b 4 5 d 0 7 b 1 e 7 9 e 5 a 8 4 e 5 7 4 1 3 7 f f 6 e 4 6 [ 1 ] . j p g q| p Z 9 bieß È¶ß È¶ß ÈÔh9Y¡È Ð èÇ 5 3 B B 4 5 ~ 1 . J P G ] . j Ü x d 9 çæcÈ5õcÈ5õcÈ5õcÈ l 5 4 4 2 _ t h u m b [ 1 ] . j p g Ü p Z 9 çæcÈ5õcÈ5õcÈ5õcÈ l 5 4 4 2 _ T ~ 1 . J P G f d5 p \ 9 PÄöèÈPÄöèÈPÄöèÈPÄöèÈ ³ (
6 0 0 x 2 4 [ 1 ] . g i f d5 p Z 9 PÄöèÈPÄöèÈPÄöèÈPÄöèÈ ³ 6 0 0 X 2 4 ~ 1 . G I F | h T 9 ¼Ëgß È¼Ëgß È¼Ëgß È¼Ëgß È
6 5 [ 1 ] . j p g [ 1 | h X 9 ¼Ëgß È¼Ëgß È¼Ëgß È¼Ëgß È
6 5 _ 1 _ ~ 1 . J P G Þ "