Author: Copyright � 2006, MetaQuotes Software Corp.
DeltaAlert

This technical tool is designed to help traders identify specific momentum shifts and price trends by measuring the distance between current market prices and two different moving averages. Instead of looking at the price movements directly on a standard chart, this script calculates "deviations"—essentially tracking how far away the price has wandered from its average path.

How the Logic Works

The script operates by comparing the current closing price against two distinct Exponential Moving Averages (EMAs):

  • A Long-Term Average: Based on a larger timeframe (defaulting to 60 periods).
  • A Short-Term Average: Based on a smaller, faster-reacting timeframe (defaulting to 13 periods).

By calculating the numerical difference between these averages and the current price, the tool creates two separate visual lines. These lines represent the "gap" or "delay" between the market's immediate action and its broader trend.

Signal Generation

The core logic focuses on the interaction between these two deviation values. The script identifies trading opportunities by looking for "crossovers" in these deviations:

  • Buy Signals: When the short-term deviation becomes greater than the long-term deviation, the script recognizes a potential bullish momentum shift.
  • Sell Signals: Conversely, when the long-term deviation becomes greater than the short-term deviation, it signals a potential bearish momentum shift.

Key Features for the User

  • Visual Feedback: The tool renders two distinct lines (Blue and Red) in a separate window below your main chart, allowing you to monitor these deviations in real-time.
  • Automated Alerts: To ensure you don't miss a potential entry point, the script features a built-in notification system. When a crossover occurs on the most recent price bar, it triggers a pop-up alert providing the current Ask and Bid prices, the exact time of the signal, and the currency symbol being traded.
  • Smart Filtering: The logic includes a safety mechanism to prevent "alert fatigue" by ensuring that notifications are only triggered once per specific move, rather than repeating on every tick of the price.

By focusing on the mathematical relationship between different moving averages rather than just raw price action, this script aims to provide a clearer picture of market momentum and potential reversal points.

Price Data Components
Series array that contains open time of each bar
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
DeltaAlert
//+------------------------------------------------------------------+
//|                                                        SmWPR.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters

extern int       sper=60;
extern int       fper=13;
extern int       test=0;
extern int       nBars=100;
extern bool      AlertON=true;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double shift, sdel, fdel, mas, maf, mBar;
double alertBar;

int flagval1 = 0;
int flagval2 = 0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"sdel");
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"fdel");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

      for(int shift=Bars-1; shift>0; shift--)
      {
         ExtMapBuffer1[shift]=0;
         ExtMapBuffer2[shift]=0;
      }
   
      if (test==1) {mBar=nBars;} else {mBar=Bars;}

      for(shift=Bars-1; shift>0; shift--)
      {
         mas=iMA(NULL, 0, sper, 0, MODE_EMA, PRICE_CLOSE,shift-1);
         maf=iMA(NULL, 0, fper, 0, MODE_EMA, PRICE_CLOSE,shift-1);
         sdel=MathRound((mas-Close[0])/Point);
         fdel=MathRound((maf-Close[0])/Point);
         if (sdel==0) {sdel=0.0001;}
         if (fdel==0) {fdel=0.0001;}
         if (sdel!=0) {ExtMapBuffer1[shift-1]=sdel;}
         if (fdel!=0) {ExtMapBuffer2[shift-1]=fdel;}
         
        if (fdel > sdel)
        {
         if (flagval1==0)
         {
           flagval1=1;
           flagval2=0;
           if (shift == 1 && AlertON && Bars>alertBar) {Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());alertBar = Bars;}
         }

        }
        else if (fdel < sdel) 
        {
         if ( flagval2==0)
         {
          flagval2=1;
          flagval1=0;
          if (shift == 1 && AlertON && Bars>alertBar) {Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());alertBar = Bars;}
         }
        
        }
      }
   
   return(0);
  }
//+------------------------------------------------------------------+

Comments