AO_alert

This tool is a specialized technical indicator designed to help traders visualize market momentum and identify potential trend reversals. It functions by analyzing price movements over two different time horizons simultaneously to determine the "strength" of the current trend.

Core Logic and Visual Representation

The script operates in three main stages to provide a clear picture of market behavior:

1. Momentum Calculation (The Foundation) The core logic begins by comparing two different types of moving averages: a fast-moving average (representing short-term price action) and a slow-moving average (representing long-term trends). By subtracting the slow average from the fast one, the script calculates the "distance" between current momentum and historical trends. This value represents how much the price is pulling away or returning to its average.

2. Visual Separation of Trends To make this data easy to read at a glance, the script separates these results into two distinct visual colors:

  • Upward Momentum: When the momentum is increasing compared to the previous period, it is highlighted in one color (DeepSkyBlue).
  • Downward Momentum: When the momentum is decreasing or falling, it is highlighted in a contrasting color (Crimson). This allows a user to instantly see whether the market "energy" is currently expanding or contracting.

3. Intelligent Signal Alerts Beyond just providing a visual chart, the script includes an automated logic system to notify the user of specific trend shifts:

  • Trend Detection: The script monitors for "turning points." It looks for specific sequences where the momentum values shift direction consecutively over multiple bars.
  • Alert System: When the script detects a confirmed shift in momentum—such as a transition from falling energy to rising energy—it triggers a real-time notification (Alert).
  • Filtering: The logic is designed to be "smart" by ensuring it only processes new data at the start of a new candle. This prevents the script from sending multiple repetitive alerts for the same price movement, providing a cleaner experience for the user.

Summary for the User

In simple terms, this tool acts as a momentum speedometer. It tells you not just if the price is moving up or down, but how fast and strongly it is moving in that direction. By highlighting these shifts in different colors and providing automated alerts when the momentum "flips," it helps traders identify potential entry or exit points based on the underlying strength of the market trend.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
15 Views
0 Downloads
0 Favorites
AO_alert
//+------------------------------------------------------------------+
//|                                                      Awesome.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  DeepSkyBlue
#property  indicator_color3  Crimson

//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
// Íîìåð áàðà, ïî êîòîðîìó áóäåò èñêàòüñÿ ñèãíàë
#define SIGNAL_BAR 1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,4);
   IndicatorDigits(Digits+1);
   SetIndexDrawBegin(0,34);
   SetIndexDrawBegin(1,34);
   SetIndexDrawBegin(2,34);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AO");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd
   for(int i=0; i<limit; i++)
      ExtBuffer0[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
//---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
     }
//---- done
//---- Ñòàòè÷åñêèå ïåðåìåííûå, â êîòîðûõ õðàíÿòñÿ
//---- âðåìÿ ïîñëåäíåãî áàðà è íàïðàâëåíèå ïîñëåäíåãî ñèãíàëà
	  static int PrevSignal = 0, PrevTime = 0;
//---- Åñëè áàðîì äëÿ àíàëèçà âûáðàí íå 0-é, íàì íåò ñìûñëà ïðîâåðÿòü ñèãíàë
//---- íåñêîëüêî ðàç. Åñëè íå íà÷àëñÿ íîâûé áàð, âûõîäèì.
	  if(SIGNAL_BAR > 0 && Time[0] <= PrevTime ) 
	      return(0);
//---- Îòìå÷àåì, ÷òî ýòîò áàð ïðîâåðåí
	  PrevTime = Time[0];
//---- Åñëè ïðåäûäóùèé ñèãíàë áûë ÑÅËË èëè ýòî ïåðâûé çàïóñê (PrevSignal=0)
	  if(PrevSignal <= 0)
	    {
		     if(ExtBuffer0[SIGNAL_BAR] - ExtBuffer0[SIGNAL_BAR+1] > 0 &&
				      ExtBuffer0[SIGNAL_BAR+2] - ExtBuffer0[SIGNAL_BAR+1] > 0 )
		       {
			        PrevSignal = 1;
			        Alert("Awesome (", Symbol(), ", ", Period(), ")  - GREEN!!!");
		       }
	    }
	  if(PrevSignal >= 0)
	    {
		     if(ExtBuffer0[SIGNAL_BAR+1] - ExtBuffer0[SIGNAL_BAR] > 0 &&
				      ExtBuffer0[SIGNAL_BAR+1] - ExtBuffer0[SIGNAL_BAR+2] > 0)
		       {
			        PrevSignal = -1;
			        Alert("AO (", Symbol(), ", ", Period(), ")  - RED!!!");
		       }
	    }
   return(0);
  }
//+------------------------------------------------------------------+

Comments