envelope alert

Download script
envelope alert

This automated trading tool is designed to act as a real-time monitoring system that tracks the price of a financial asset relative to three specific mathematical boundaries: a Moving Average, an Upper Envelope, and a Lower Envelope. Its primary purpose is to notify you immediately whenever the market price enters or touches these designated zones.

How the Logic Works

The script continuously calculates three distinct reference lines on your chart:

  • The Central Line (Moving Average): This represents the "smoothed" trend of the price over a specific period. It helps identify the general direction and average value of the market.
  • The High Envelope: This acts as an upper boundary, calculated by taking the Moving Average and adding a specific percentage of deviation to it. It essentially marks a "ceiling."
  • The Low Envelope: This acts as a lower boundary, calculated by subtracting that same percentage of deviation from the Moving Average. It effectively marks a "floor."

Notification Triggers

The core logic of the script is built around a "proximity detection" system. Instead of only alerting you when the price exactly hits a line, the script uses a customizable range (a small buffer zone).

The tool constantly monitors the current market price. If the price enters this tiny buffer zone around any of the three boundaries, the script triggers two simultaneous actions:

  1. Visual/Audio Alerts: An immediate pop-up notification appears on your trading platform screen to grab your attention.
  2. Email Notifications: A message is automatically sent to your registered email address, providing you with the specific asset name and the exact price at which the boundary was reached.

Summary of Use

This tool is intended for traders who want to be alerted when price action interacts with key technical levels. By automating the monitoring of these three boundaries, it ensures that you are notified of potential trend reversals or breakouts in real-time, even if you aren't actively watching the charts at every moment.

Indicators Used
Moving average indicatorEnvelopes indicator
Miscellaneous
It issuies visual alerts to the screen
17 Views
0 Downloads
0 Favorites
envelope alert

extern int range = 1;
extern int ma_period = 62;
extern int ma_shift = 0;
extern int ma_method = MODE_EMA;
extern int applied_price = PRICE_CLOSE;
extern double deviation = 0.05;
 
#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);
   double envb = iEnvelopes( Symbol(), 0, ma_period, ma_method, ma_shift, applied_price, deviation, MODE_UPPER,0);
   double envs = iEnvelopes( Symbol(), 0, ma_period, ma_method, ma_shift, applied_price, deviation, MODE_LOWER,0);
   
   
   if( (Bid <= ma+(range*Point)) && (Bid >= ma-(range*Point)))
   {
   Alert(Symbol()+" "+ma_period+" Moving Average range reached at ",Bid);
   SendMail ("Alert on " + Symbol(), Symbol()+" "+ma_period+" Moving Average range reached at " + Bid);
   } 
   
   if( (Bid <= envb+(range*Point)) && (Bid >= envb-(range*Point)))
   {
   Alert(Symbol()+" "+ma_period+" High envelope range reached at ",Bid);
   SendMail ("Alert on " + Symbol(), Symbol()+" "+ma_period+" High envelope range reached at " + Bid);
   } 
   
   if( (Bid <= envs+(range*Point)) && (Bid >= envs-(range*Point)))
   {
   Alert(Symbol()+" "+ma_period+" Low envelope range reached at ",Bid);
   SendMail ("Alert on " + Symbol(), Symbol()+" "+ma_period+" Low envelope range reached at " + Bid);
   } 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments