QQE_Alert_MTF_v5##

Download script
Author: Copyright � 2007, MetaQuotes Software Corp.
QQE_Alert_MTF_v5##

This script is a custom technical analysis tool designed to monitor price movements and momentum on trading platforms. It functions by calculating several layers of mathematical data to identify trend changes, specifically focusing on "crossovers"—moments when one moving average line crosses another or a specific threshold.

Core Mathematical Logic

The tool builds its logic through a multi-step processing chain:

  1. Momentum Base: It begins by looking at the Relative Strength Index (RSI), a standard measure of whether an asset is overbought or oversold.
  2. Smoothing: The script applies an Exponential Moving Average (EMA) to that RSI data to create a smoother line, filtering out minor "noise" in the price action.
  3. Volatility and Trend Tracking: It calculates the difference between high and low values of this smoothed data and applies further moving averages. This creates a foundation for identifying the strength and direction of the current trend.
  4. Dynamic Boundary Lines: The script generates two distinct dynamic lines (often referred to in trading as "trailing" or "signal" lines). These lines adjust based on specific multipliers (2.618 and 4.236) applied to the moving averages, effectively acting as boundaries that track the trend's expansion and contraction.

Visual Indicators and Alerts

The primary purpose of this logic is to notify the user when specific "events" occur on the chart. The script monitors for three main types of occurrences:

  • The 50-Line Break: The script watches the primary smoothed line as it crosses the "50" level (a neutral midpoint). A move above 50 suggests bullish momentum, while a move below 50 suggests bearish momentum.
  • Line Crossovers: The script tracks when the primary smoothed line crosses the secondary dynamic boundary lines. These crossovers are used to identify potential trend reversals or significant shifts in price behavior.
  • Combined Signals: The tool is capable of identifying "Double Signals," where both a 50-line break and a dynamic line crossover happen simultaneously, suggesting a high-confidence trend change.

Notification System

When any of the conditions above are met, the script can execute several actions based on user preferences:

  • Visual Cues: It can place specific colored dots (arrows) directly on the chart at the exact moment a crossover occurs, allowing traders to see historical signals easily.
  • Auditory Alerts: It can trigger specific sound files to grab the trader's attention in real-time.
  • Text Notifications: It prints messages on the screen and in the system log, detailing the price, time, and type of signal detected.
  • Email Alerts: For traders who are away from their screens, it can send automated email notifications to mobile devices or computers whenever a significant trend shift is identified.
Indicators Used
Relative strength indexMoving average indicator
Miscellaneous
It plays sound alertsIt sends emails
6 Views
0 Downloads
0 Favorites
QQE_Alert_MTF_v5##
/*
   Generated by EX4-TO-MQ4 decompiler V4.0.220.2 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_levelcolor Red
#property indicator_levelstyle 0
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 CLR_NONE
#property indicator_color3 Black
#property indicator_width1 2
#property indicator_level1 50.0

double g_ibuf_76[];
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double g_ibuf_104[];
extern int Smoothing = 5;
extern int TimeFrame = 0;
extern string ALERTS = "------------------------------------------------------";
extern bool CrossFiftyAlert = FALSE;
extern bool CrossFiftyEmail = FALSE;
extern bool CrossLineAlert = FALSE;
extern bool CrossLineEmail = FALSE;
extern bool BothAlert = FALSE;
extern bool BothEmail = FALSE;
extern string MESSAGES = "------------------------------------------------------";
extern string FiftyUpMessage = "QQE Crossed 50 Line UP !!!";
extern string FiftyDownMessage = "QQE Crossed 50 Line DOWN !!!";
extern string QQECrossUpMessage = "QQE Lines Crossed UP !!!";
extern string QQECrossDownMessage = "QQE Lines Crossed DOWN !!!";
extern string BothUpMessage = "QQE Lines Are Crossed and 50 Line Broken UP !!!";
extern string BothDownMessage = "QQE Lines Are Crossed and 50 Line Broken DOWN !!!";
extern string SOUNDS = "------------------------------------------------------";
extern string FiftyUpSound = "alert.wav";
extern string FiftyDownSound = "alert.wav";
extern string QQECrossUpSound = "alert.wav";
extern string QQECrossDownSound = "alert.wav";
extern string BothUpSound = "alert.wav";
extern string BothDownSound = "alert.wav";
extern string DOT_VISIBILITY = "------------------------------------------------------";
extern bool FiftyUpDot = FALSE;
extern bool FiftyDownDot = FALSE;
extern bool QQECrossUpDot = FALSE;
extern bool QQECrossDownDot = FALSE;
extern bool BothUpDot = FALSE;
extern bool BothDownDot = FALSE;
extern string DOT_COLORS = "------------------------------------------------------";
extern color FiftyUpColor = DodgerBlue;
extern color FiftyDownColor = Crimson;
extern color QQECrossUpColor = Teal;
extern color QQECrossDownColor = Pink;
extern color BothUpColor = Blue;
extern color BothDownColor = Red;
extern string DOT_DISTANCE = "------------------------------------------------------";
extern int Distance = 30;
int gi_unused_336 = 0;
int gi_unused_340 = 0;
int gi_344 = 0;

int init() {
   string ls_unused_8;
   string ls_20;
   IndicatorBuffers(8);
   SetIndexBuffer(0, g_ibuf_80);
   SetIndexBuffer(1, g_ibuf_84);
   SetIndexBuffer(2, g_ibuf_88);
   SetIndexBuffer(3, g_ibuf_76);
   SetIndexBuffer(4, g_ibuf_92);
   SetIndexBuffer(5, g_ibuf_96);
   SetIndexBuffer(6, g_ibuf_100);
   SetIndexBuffer(7, g_ibuf_104);
   switch (TimeFrame) {
   case 1:
      ls_20 = "Period_M1";
      break;
   case 5:
      ls_20 = "Period_M5";
      break;
   case 15:
      ls_20 = "Period_M15";
      break;
   case 30:
      ls_20 = "Period_M30";
      break;
   case 60:
      ls_20 = "Period_H1";
      break;
   case 240:
      ls_20 = "Period_H4";
      break;
   case 1440:
      ls_20 = "Period_D1";
      break;
   case 10080:
      ls_20 = "Period_W1";
      break;
   case 43200:
      ls_20 = "Period_MN1";
      break;
   default:
      ls_20 = "Current Timeframe";
   }
   MathSrand(TimeLocal());
   string ls_0 = "QQE " + ls_20;
   IndicatorShortName(ls_0);
   return (0);
}

int deinit() {
   string l_name_4;
   for (int li_0 = 32768; li_0 > 0; li_0--) {
      l_name_4 = "QQE-" + li_0;
      ObjectDelete(l_name_4);
   }
   return (0);
}

int start() {
   int lia_20[];
   double ld_28;
   double ld_36;
   int li_44;
   string l_name_48;
   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   int li_24 = Bars - li_0;
   int li_unused_12 = Smoothing;
   ArrayCopySeries(lia_20, 5, Symbol(), TimeFrame);
   int li_4 = 0;
   int li_8 = 0;
   while (li_4 < li_24) {
      if (Time[li_4] < lia_20[li_8]) li_8++;
      g_ibuf_76[li_4] = iRSI(NULL, TimeFrame, 14, PRICE_CLOSE, li_8);
      li_4++;
   }
   li_4 = 0;
   li_8 = 0;
   while (li_4 < li_24) {
      if (Time[li_4] < lia_20[li_8]) li_8++;
      g_ibuf_80[li_8] = iMAOnArray(g_ibuf_76, 0, Smoothing, 0, MODE_EMA, li_8);
      li_4++;
   }
   for (li_4 = 0; li_4 < li_24; li_4++) {
      ld_28 = MathMax(g_ibuf_80[li_4 + 1], g_ibuf_80[li_4]);
      ld_36 = MathMin(g_ibuf_80[li_4 + 1], g_ibuf_80[li_4]);
      g_ibuf_96[li_4] = ld_28 - ld_36;
   }
   for (li_4 = 0; li_4 < li_24; li_4++) g_ibuf_92[li_4] = iMAOnArray(g_ibuf_96, 0, 27, 0, MODE_EMA, li_4);
   for (li_4 = 0; li_4 < li_24; li_4++) g_ibuf_100[li_4] = 2.618 * iMAOnArray(g_ibuf_92, 0, 27, 0, MODE_EMA, li_4);
   for (li_4 = li_24; li_4 >= 0; li_4--) {
      if (g_ibuf_80[li_4] == g_ibuf_84[li_4 + 1]) g_ibuf_84[li_4] = g_ibuf_80[li_4];
      else {
         if (g_ibuf_80[li_4 + 1] < g_ibuf_84[li_4 + 1] && g_ibuf_80[li_4] < g_ibuf_84[li_4 + 1]) g_ibuf_84[li_4] = MathMin(g_ibuf_84[li_4 + 1], g_ibuf_80[li_4] + g_ibuf_100[li_4]);
         else {
            if (g_ibuf_80[li_4 + 1] > g_ibuf_84[li_4 + 1] && g_ibuf_80[li_4] > g_ibuf_84[li_4 + 1]) g_ibuf_84[li_4] = MathMax(g_ibuf_84[li_4 + 1], g_ibuf_80[li_4] - g_ibuf_100[li_4]);
            else {
               if (g_ibuf_80[li_4] > g_ibuf_84[li_4 + 1]) g_ibuf_84[li_4] = g_ibuf_80[li_4] - g_ibuf_100[li_4];
               else g_ibuf_84[li_4] = g_ibuf_80[li_4] + g_ibuf_100[li_4];
            }
         }
      }
   }
   for (li_4 = 0; li_4 < li_24; li_4++) g_ibuf_104[li_4] = 4.236 * iMAOnArray(g_ibuf_92, 0, 27, 0, MODE_EMA, li_4);
   for (li_4 = li_24; li_4 >= 0; li_4--) {
      if (g_ibuf_80[li_4] == g_ibuf_88[li_4 + 1]) g_ibuf_88[li_4] = g_ibuf_80[li_4];
      else {
         if (g_ibuf_80[li_4 + 1] < g_ibuf_88[li_4 + 1] && g_ibuf_80[li_4] < g_ibuf_88[li_4 + 1]) g_ibuf_88[li_4] = MathMin(g_ibuf_88[li_4 + 1], g_ibuf_80[li_4] + g_ibuf_104[li_4]);
         else {
            if (g_ibuf_80[li_4 + 1] > g_ibuf_88[li_4 + 1] && g_ibuf_80[li_4] > g_ibuf_88[li_4 + 1]) g_ibuf_88[li_4] = MathMax(g_ibuf_88[li_4 + 1], g_ibuf_80[li_4] - g_ibuf_104[li_4]);
            else {
               if (g_ibuf_80[li_4] > g_ibuf_88[li_4 + 1]) g_ibuf_88[li_4] = g_ibuf_80[li_4] - g_ibuf_104[li_4];
               else g_ibuf_88[li_4] = g_ibuf_80[li_4] + g_ibuf_104[li_4];
            }
         }
      }
   }
   if (gi_344 == Time[0]) return (0);
   for (li_4 = li_24 - 1; li_4 >= 0; li_4--) {
      if (g_ibuf_80[li_4 + 1] > 50.0 && g_ibuf_80[li_4 + 2] <= 50.0 && FiftyUpDot) {
         li_44 = MathRand() + 1;
         l_name_48 = "QQE-" + li_44;
         ObjectCreate(l_name_48, OBJ_ARROW, 0, Time[li_4], Low[li_4] - Distance * Point);
         ObjectSet(l_name_48, OBJPROP_COLOR, FiftyUpColor);
         ObjectSet(l_name_48, OBJPROP_ARROWCODE, 108);
      }
      if (g_ibuf_80[li_4 + 1] < 50.0 && g_ibuf_80[li_4 + 2] >= 50.0 && FiftyDownDot) {
         li_44 = MathRand() + 1;
         l_name_48 = "QQE-" + li_44;
         ObjectCreate(l_name_48, OBJ_ARROW, 0, Time[li_4], High[li_4] + Distance * Point);
         ObjectSet(l_name_48, OBJPROP_COLOR, FiftyDownColor);
         ObjectSet(l_name_48, OBJPROP_ARROWCODE, 108);
      }
      if (g_ibuf_80[li_4 + 1] > g_ibuf_88[li_4 + 1] && g_ibuf_80[li_4 + 2] < g_ibuf_88[li_4 + 2] && QQECrossUpDot) {
         li_44 = MathRand() + 1;
         l_name_48 = "QQE-" + li_44;
         ObjectCreate(l_name_48, OBJ_ARROW, 0, Time[li_4], Low[li_4] - Distance * Point);
         ObjectSet(l_name_48, OBJPROP_COLOR, QQECrossUpColor);
         ObjectSet(l_name_48, OBJPROP_ARROWCODE, 108);
      }
      if (g_ibuf_80[li_4 + 1] < g_ibuf_88[li_4 + 1] && g_ibuf_80[li_4 + 2] > g_ibuf_88[li_4 + 2] && QQECrossDownDot) {
         li_44 = MathRand() + 1;
         l_name_48 = "QQE-" + li_44;
         ObjectCreate(l_name_48, OBJ_ARROW, 0, Time[li_4], High[li_4] + Distance * Point);
         ObjectSet(l_name_48, OBJPROP_COLOR, QQECrossDownColor);
         ObjectSet(l_name_48, OBJPROP_ARROWCODE, 108);
      }
      if ((g_ibuf_80[li_4 + 1] > g_ibuf_88[li_4 + 1] && (g_ibuf_80[li_4 + 1] > 50.0 && g_ibuf_80[li_4 + 2] <= 50.0)) || (g_ibuf_80[li_4 + 1] > g_ibuf_88[li_4 + 1] && g_ibuf_80[li_4 +
         2] < g_ibuf_88[li_4 + 2] && g_ibuf_80[li_4 + 1] > 50.0) && BothUpDot) {
         li_44 = MathRand() + 1;
         l_name_48 = "QQE-" + li_44;
         ObjectCreate(l_name_48, OBJ_ARROW, 0, Time[li_4], Low[li_4] - Distance * Point);
         ObjectSet(l_name_48, OBJPROP_COLOR, BothUpColor);
         ObjectSet(l_name_48, OBJPROP_ARROWCODE, 108);
      }
      if ((g_ibuf_80[li_4 + 1] < g_ibuf_88[li_4 + 1] && (g_ibuf_80[li_4 + 1] < 50.0 && g_ibuf_80[li_4 + 2] >= 50.0)) || (g_ibuf_80[li_4 + 1] < g_ibuf_88[li_4 + 1] && g_ibuf_80[li_4 +
         2] > g_ibuf_88[li_4 + 2] && g_ibuf_80[li_4 + 1] < 50.0) && BothDownDot) {
         li_44 = MathRand() + 1;
         l_name_48 = "QQE-" + li_44;
         ObjectCreate(l_name_48, OBJ_ARROW, 0, Time[li_4], High[li_4] + Distance * Point);
         ObjectSet(l_name_48, OBJPROP_COLOR, BothDownColor);
         ObjectSet(l_name_48, OBJPROP_ARROWCODE, 108);
      }
   }
   if (g_ibuf_80[1] > 50.0 && g_ibuf_80[2] <= 50.0) {
      if (CrossFiftyAlert) {
         Print(Symbol(), " ", Period(), "M   ", FiftyUpMessage, "   @   ", Bid, " + ", Ask - Bid, " = ", Ask);
         Comment(Symbol(), " ", Period(), "M   ", FiftyUpMessage, "   @   ", Bid, " + ", Ask - Bid, " = ", Ask, 
         "\n", "TIME ON ALERT IS : ", TimeToStr(TimeCurrent()));
         PlaySound(FiftyUpSound);
      }
      if (CrossFiftyEmail) SendMail(FiftyUpMessage + Symbol(), " !!! ");
   }
   if (g_ibuf_80[1] < 50.0 && g_ibuf_80[2] >= 50.0) {
      if (CrossFiftyAlert) {
         Print(Symbol(), " ", Period(), "M   ", FiftyDownMessage, "   @   ", Bid);
         Comment(Symbol(), " ", Period(), "M   ", FiftyDownMessage, "   @   ", Bid, 
         "\n", "TIME ON ALERT IS : ", TimeToStr(TimeCurrent()));
         PlaySound(FiftyDownSound);
      }
      if (CrossFiftyEmail) SendMail(FiftyDownMessage + Symbol(), " !!! ");
   }
   if (g_ibuf_80[1] > g_ibuf_88[1] && g_ibuf_80[2] < g_ibuf_88[2]) {
      if (CrossLineAlert) {
         Print(Symbol(), " ", Period(), "M   ", QQECrossUpMessage, "   @   ", Bid, " + ", Ask - Bid, " = ", Ask);
         Comment(Symbol(), " ", Period(), "M   ", QQECrossUpMessage, "   @   ", Bid, " + ", Ask - Bid, " = ", Ask, 
         "\n", "TIME ON ALERT IS : ", TimeToStr(TimeCurrent()));
         PlaySound(QQECrossUpSound);
      }
      if (CrossLineEmail) SendMail(QQECrossUpMessage + Symbol(), " !!! ");
   }
   if (g_ibuf_80[1] < g_ibuf_88[1] && g_ibuf_80[2] > g_ibuf_88[2]) {
      if (CrossLineAlert) {
         Print(Symbol(), " ", Period(), "M   ", QQECrossDownMessage, "   @   ", Bid);
         Comment(Symbol(), " ", Period(), "M   ", QQECrossDownMessage, "   @   ", Bid, 
         "\n", "TIME ON ALERT IS : ", TimeToStr(TimeCurrent()));
         PlaySound(QQECrossDownSound);
      }
      if (CrossLineEmail) SendMail(QQECrossDownMessage + Symbol(), " !!! ");
   }
   if ((g_ibuf_80[li_4 + 1] > g_ibuf_88[1] && (g_ibuf_80[1] > 50.0 && g_ibuf_80[2] <= 50.0)) || (g_ibuf_80[1] > g_ibuf_88[li_4 + 1] && g_ibuf_80[2] < g_ibuf_88[2] && g_ibuf_80[1] > 50.0) &&
      BothUpDot) {
      if (BothAlert) {
         Print(Symbol(), " ", Period(), "M   ", BothUpMessage, "   @   ", Bid);
         Comment(Symbol(), " ", Period(), "M   ", BothUpMessage, "   @   ", Bid, 
         "\n", "TIME ON ALERT IS : ", TimeToStr(TimeCurrent()));
         PlaySound(BothUpSound);
      }
      if (BothEmail) SendMail(BothUpMessage + Symbol(), " !!! ");
   }
   if ((g_ibuf_80[1] < g_ibuf_88[1] && (g_ibuf_80[1] < 50.0 && g_ibuf_80[2] >= 50.0)) || (g_ibuf_80[1] < g_ibuf_88[1] && g_ibuf_80[2] > g_ibuf_88[2] && g_ibuf_80[1] < 50.0) &&
      BothDownDot) {
      if (BothAlert) {
         Print(Symbol(), " ", Period(), "M   ", BothDownMessage, "   @   ", Bid);
         Comment(Symbol(), " ", Period(), "M   ", BothDownMessage, "   @   ", Bid, 
         "\n", "TIME ON ALERT IS : ", TimeToStr(TimeCurrent()));
         PlaySound(BothDownSound);
      }
      if (BothEmail) SendMail(BothDownMessage + Symbol(), " !!! ");
   }
   gi_344 = Time[0];
   return (0);
}

Comments