guppy34_alert
Download scriptThis script is designed as a visual trend-following tool for the MetaTrader trading platform. Its primary purpose is to monitor price movements and provide clear, real-time signals regarding whether the current market direction is moving upward or downward.
Core Functionality
The logic operates by calculating a Moving Average (MA), which is a common technical analysis tool that smooths out price fluctuations to reveal the underlying trend. By analyzing the relationship between the current value of this average and its previous value, the script determines the "momentum" of the market.
How it Works
- Trend Detection: The script constantly compares the most recent data points of the Moving Average. If the current value is higher than the previous one, it identifies an upward trend. Conversely, if the current value is lower, it identifies a downward trend.
- Visual Feedback: To make these trends easy for the user to see on a chart, the script uses two distinct visual lines (colored Red and Lime). It dynamically hides and shows sections of these lines based on the detected movement, allowing traders to visually track shifts in market direction.
- Smart Signaling: The system is designed to ignore "noise" by tracking state changes. It won't continuously trigger a notification for every single bar; instead, it only triggers an alert at the specific moment the trend flips (e.g., from moving up to moving down).
Notifications and Alerts
Beyond just drawing lines on a chart, the script includes a notification system to keep traders informed even when they are not looking at their screens:
- On-Screen Alerts: The software can trigger an immediate audible/pop-up alert the moment a trend reversal is detected.
- Email Notifications: If enabled by the user, the script can automatically send an email containing the specific symbol and timeframe where the upward or downward signal occurred.
Summary for the User
Essentially, this tool acts as a "trend watcher." It automates the tedious task of comparing moving averages across different time intervals and translates that data into clear visual cues and proactive notifications, helping you identify potential market turns more efficiently.
//+------------------------------------------------------------------+
//| |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, FX Sniper "
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Lime
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[],ma[];
extern int MAType = 1;
extern int MAPeriod = 34;
extern int MAShift = 0;
extern int PriceType=0;
extern bool Turn_ON_Alert =True;
extern bool send_mail = False;
int signal =0, signalUp =0, signalDown =0;
datetime PreviousBar;
bool init_variables;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
init_variables = true;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(5);
//---- drawing settings
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ma);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
//---- initialization done
return(0);
}
int start()
{
string Message;
for(int i = Bars-10; i >= 0; i--)
{
ma[i]=iMA(NULL,0,MAPeriod,MAShift,MAType,PriceType,i);
}
for(int shift = Bars-10; shift >= 0; shift--)
{
ExtMapBuffer1[shift] = ma[shift];
ExtMapBuffer2[shift] = ma[shift];
//Print (ma[shift]);
if (ma[shift] > ma[shift+1])
{
ExtMapBuffer1[shift] = EMPTY_VALUE;
ExtMapBuffer2[shift+1] = ma[shift+1];
signal =1;
}
else if (ma[shift] < ma[shift+1])
{
ExtMapBuffer2[shift] = EMPTY_VALUE;
ExtMapBuffer1[shift+1] = ma[shift+1];
signal =2;
}
}
if(init_variables == true)
{
PreviousBar = Time[0];
init_variables = false;
}
if(PreviousBar<Time[0])
{
PreviousBar = Time[0];
if(signal ==1 && signalUp !=1)
{
signalUp = 1;
signalDown = 0;
Message=" Signal indicate "+Symbol()+" M"+Period()+" going UP";
if(Turn_ON_Alert == True)
{
Alert (Message);
}
if(send_mail ==True)
{
SendMail("[Signal Alert]", "[" + Symbol() +" M"+Period()+" going UP");
}
return(0);
}
if(signal ==2 && signalDown !=1)
{
signalDown = 1;
signalUp = 0;
Message=" Signal indicate "+Symbol()+" M"+Period()+" going DOWN";
if(Turn_ON_Alert == True)
{
Alert (Message);
}
if(send_mail ==True)
{
SendMail("[Signal Alert]", "[" + Symbol() +" M"+Period()+" going DOWN");
}
return(0);
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments