Filter_AO Alert

Download script
Filter_AO Alert

This tool is designed as a visual aid for traders to help identify momentum shifts and potential entry points in the financial markets. It functions by analyzing price trends and filtering them into a clear, color-coded visual display.

Core Logic and Mechanism

The script works by performing three main tasks: calculating a trend baseline, determining directional momentum, and generating real-time notifications.

1. Trend Calculation The foundation of the tool is based on a mathematical comparison between two different moving averages. It looks at the recent price history (a short-term average) and compares it against a much longer historical average. The difference between these two values tells the script how fast the price is moving in a specific direction.

2. Momentum Filtering (The Visuals) Instead of showing you raw, messy data, the tool organizes the information into two distinct visual categories:

  • Positive Momentum: When the trend is moving upward, the tool highlights this with a Lime color.
  • Negative Momentum: When the trend moves downward, it switches to a Red color.

By separating the data this way, the tool allows you to see at a glance whether the current "push" in the market is strengthening or weakening, making it easier to distinguish between active trends and stagnant price action.

3. Signal Identification and Alerts The script is programmed to recognize specific "pivot points"—moments where the momentum changes direction significantly. Specifically:

  • Buy Signals: When the trend moves from a downward state into an upward move, the tool triggers a visual color change and sends an automated "Buy" alert.
  • Sell Signals: When the trend moves from an upward state into a downward move, it triggers a "Sell" alert.

How to Use This Information

Essentially, this script acts as a momentum filter. Rather than making you guess where the price is headed, it cleans up the market noise and visually signals when the "mood" of the market shifts from bullish to bearish (or vice versa). It provides a streamlined way to track market velocity while providing proactive alerts so you don't have to watch the screen constantly to catch a trend reversal.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
4 Views
0 Downloads
0 Favorites
Filter_AO Alert
//+------------------------------------------------------------------+
//|                                                    Filter_AO.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
#property  link      "Alert by GOEN"

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Lime
#property  indicator_color2  Red
//---- indicator buffers
double     ind_buffer1[];
double     ind_buffer2[];
double     ind_buffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 1 additional buffer used for counting.
   IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   SetIndexDrawBegin(0,34);
   SetIndexDrawBegin(1,34);
//---- 3 indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) &&
      !SetIndexBuffer(1,ind_buffer2) &&
      !SetIndexBuffer(2,ind_buffer3))
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Filter_AO");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Awesome Oscillator                                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev,current;
   static datetime lastalert;
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st additional buffer
   for(int i=0; i<limit; i++)
      ind_buffer3[i]=iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,102,0,MODE_EMA,PRICE_CLOSE,i);
//---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
      current=ind_buffer3[i];
      prev=ind_buffer3[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ind_buffer2[i]=current;
         ind_buffer1[i]=0.0;
        }
      else
        {
         ind_buffer1[i]=current;
         ind_buffer2[i]=0.0;
        }
     }
   
   if (ind_buffer3[0]>ind_buffer3[1] && ind_buffer3[1]<ind_buffer3[2] && lastalert!=Time[0]) 
   {  Alert("Buy (Change Color)" +Symbol());
      lastalert=Time[0];
   }
   if (ind_buffer3[0]<ind_buffer3[1] && ind_buffer3[1]>ind_buffer3[2] && lastalert!=Time[0])
   {  Alert("Sell (Change Color)" +Symbol());
      lastalert=Time[0];
   }

//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments