F2a_AO_comm_alert

Download script
F2a_AO_comm_alert

This tool is designed as a technical analysis indicator for MetaTrader platforms, specifically engineered to identify potential trend reversals or momentum shifts by analyzing price action and moving averages. It functions by calculating the relationship between fast and slow price trends to generate visual signals on your trading chart.

Core Logic and Methodology

Price Data Processing The script begins by determining how it interprets "price." Depending on the user's settings, it can calculate values based on standard market data (like the current price) or use specialized mathematical averages of the High, Low, Open, and Close prices. This allows the indicator to smooth out market noise and focus on specific price structures.

Momentum Analysis The primary engine behind this script is a variation of the "Awesome Oscillator." It calculates two different moving averages:

  • Fast Moving Average: Tracks short-term price movements quickly.
  • Slow Moving Average: Tracks long-term price trends more broadly.

By subtracting the slow average from the fast average, the script identifies the current momentum of the market. To ensure these signals are reliable, it applies a "filter"—an additional moving average that verifies whether the momentum is actually accelerating or decelerating in a consistent direction.

Signal Generation The tool looks for specific "inflection points" where the momentum shifts. It places visual markers (arrows) on the chart based on two conditions:

  • Buy Signals: These appear when the momentum indicator begins to rise significantly while the trend filter confirms a positive direction. The script detects this specific "turnaround" and places a marker below the current price.
  • Sell Signals: These appear when the momentum indicator starts to drop while the trend filter confirms a downward direction. The script identifies this shift and places a marker above the current price.

User Features

  • Visual Aids: The indicator places distinct arrows on the chart to highlight entry points, helping traders see signals at a glance without having to manually calculate data.
  • Real-Time Notifications: It includes an alert system that can trigger a pop-up notification or an audible sound the moment a new buy or sell signal is detected.
  • On-Screen Commentary: If enabled, the script will print a text comment directly on the trading chart, confirming the current trade direction (Buy/Sell) along with the specific price and time of the signal.
  • Dynamic Customization: Users can adjust the sensitivity of the moving averages and choose different calculation methods to suit different currency pairs or timeframes (e.g., adjusting for higher volatility vs. steadier trends).
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
F2a_AO_comm_alert
//+------------------------------------------------------------------+
//|                                                       F2a_AO.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//mod
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
#property  link      "Alert by GOEN"

//+------------+-----------------------------------------------------+
//  Bookkeeper: Ïîäïðàâèë íåìíîãî ïî ñâîåìó
//  Íåîáõîäèìî íàëè÷èå NavelEMA.mq4
//  Presence NavelEMA.mq4 is necessary;      opt. 4 eurusd gpbjpy H4
//+------------------------------------------------------------------+

#property  indicator_chart_window
#property  indicator_buffers 2
#property  indicator_color1  Lime
#property  indicator_color2  Red
extern int  MA_Filtr=3;
extern int  MA_Fast=13;
extern int  MA_Slow=144;
extern int  ma_method=1;
extern int  ma_price =8;
extern bool WithAlert=false;
extern bool WithComment=true;
extern int  arrDist =10;
extern string   note__Price   ="0C 1O 2H 3L 4Md 5Tp 6WghC: 4Md(HL/2),5Tp(HLC/3),6Wgh(HLCC/4)";
extern string   _______       ="7 HA close: haC =(O+H+L+C)/4";
extern string   ___           ="8 Navel MA price: nvC =(2O+H+L+5C)/9";


double up_buffer[];
double dn_buffer[];
double ind_buffer[];
double price[];
datetime lastalert=0, lastcomment=0;
//+------------------------------------------------------------------+
int deinit()
  {
   Comment("");
  }
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_ARROW);//
   SetIndexStyle(1,DRAW_ARROW);//
   SetIndexArrow(0,233); 
   SetIndexArrow(1,234); 
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexDrawBegin(0,MA_Slow+2);
   SetIndexDrawBegin(1,MA_Slow+2);
   if(!SetIndexBuffer(0,up_buffer) &&
      !SetIndexBuffer(1,dn_buffer) &&
      !SetIndexBuffer(2,ind_buffer) &&
      !SetIndexBuffer(3,price))
      Print("cannot set indicator buffers!");
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev, current;
   static datetime lastalert;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=limit; i>=0; i--)
     
    {                                                 
         if (ma_price<0 || ma_price>8)    ma_price=0;
    
      
         if (ma_price==7)       price[i]=(Close[i]+Open[i]+High[i]+Low[i])/4;  
         if (ma_price==8)       price[i]=(Close[i]*5+Open[i]*2+High[i]+Low[i])/9;

    }
      
         for(i=limit; i>=0; i--) 
         {
      
  
            if (ma_price<7) {  ind_buffer[i] =  iMA(NULL,0,MA_Fast, 0,ma_method,ma_price,i)-
                                                iMA(NULL,0,MA_Slow, 0,ma_method,ma_price,i)  ;
                               current       =  iMA(NULL,0,MA_Filtr,0,ma_method,ma_price,i)  ;
                               prev          =  iMA(NULL,0,MA_Filtr,0,ma_method,ma_price,i+1);
                            }
            
            else            { ind_buffer[i] = iMAOnArray(price,0,MA_Fast,0,ma_method,i)-
                                              iMAOnArray(price,0,MA_Slow,0,ma_method,i);
             
                               current       = iMAOnArray(price,0,MA_Filtr,0,ma_method,i) ;
                               prev          = iMAOnArray(price,0,MA_Filtr,0,ma_method,i+1);
                            }
         
         

//     ind_buffer[i]=iCustom(NULL,0,"NavelEMA",MA_Fast,0,0,i)-
//                   iCustom(NULL,0,"NavelEMA",MA_Slow,0,0,i);
     
//      current=iCustom(NULL,0,"NavelEMA",MA_Filtr,0,0,i);
//      prev=iCustom(NULL,0,"NavelEMA",MA_Filtr,0,0,i+1);
      if(ind_buffer[i]>ind_buffer[i+1] && current>=prev &&
         ind_buffer[i+1]<=ind_buffer[i+2])
            up_buffer[i]=Low[i]-Point*arrDist;
      else up_buffer[i]=0.0;
      if(ind_buffer[i]<ind_buffer[i+1] && current<=prev &&
         ind_buffer[i+1]>=ind_buffer[i+2])
            dn_buffer[i]=High[i]+Point*arrDist;
      else dn_buffer[i]=0.0;
     }
   if(WithAlert==true && lastalert!=Time[0])
   { 
      if (up_buffer[0]>Point)
      {  
         Alert("Buy " +Symbol()+"_"+Period()+" "+
               " "+DoubleToStr(MarketInfo(Symbol(),MODE_ASK),Digits)+
               " "+TimeToStr(TimeCurrent(),TIME_MINUTES));
         lastalert=Time[0];
      }
      if (dn_buffer[0]>Point)
      {  
         Alert("Sell " +Symbol()+"_"+Period()+
               " "+DoubleToStr(MarketInfo(Symbol(),MODE_BID),Digits)+
               " "+TimeToStr(TimeCurrent(),TIME_MINUTES));
         lastalert=Time[0];
      }
   }
   if(WithComment==true && lastcomment!=Time[0])
   { 
      if (up_buffer[0]>Point)
      {  
         lastcomment=Time[0];
         Comment("Buy ",Symbol(),"_",Period()," ",
               " "+DoubleToStr(Close[0],Digits));
      }
      if (dn_buffer[0]>Point)
      {  
         lastcomment=Time[0];
         Comment("Sell ",Symbol(),"_",Period(),
               " "+DoubleToStr(Close[0],Digits));
      }
   }
   return(0);
  }
//+------------------------------------------------------------------+


Comments