Alert For ZZ SuperTrend's

Download script
Author: Copyright � 2006, MetaQuotes Software Corp.
Alert For ZZ SuperTrend's

This script is designed to function as a multi-timeframe trend monitoring system for the MetaTrader 4 platform. Its primary purpose is to identify specific moments when the market trend aligns across multiple time horizons simultaneously, providing the user with immediate audible and visual notifications.

Core Logic Overview

The tool monitors four different timeframes at once: 5-minute, 15-minute, 30-minute, and 60-minute charts. It specifically looks for "SuperTrend" data from these periods to determine the current market direction. Instead of looking at just one chart, it requires a consensus across all four timeframes before it triggers an action.

How the Detection Works

The script constantly scans historical data (covering a user-defined period of days) and compares the current trend values against the previous ones. It looks for two specific "Breakout" scenarios:

  • Bullish Alignment (Upward Trend): The script triggers an alert if the trend indicators on all four timeframes simultaneously shift to a high value (indicating an upward move), specifically when at least one of those timeframes has just crossed over from a lower position.
  • Bearish Alignment (Downward Trend): Conversely, it triggers an alert if the trend indicators on all four timeframes simultaneously shift to a low value (indicating a downward move), specifically when at least one of those timeframes has just crossed over from a higher position.

Notifications and Filtering

To ensure the user is not overwhelmed with repetitive signals, the script includes a "debounce" mechanism:

  1. Alert Trigger: When the specific multi-timeframe alignment occurs, the script plays an audio file (defaulting to an email sound) and generates a pop-up alert on the screen.
  2. Signal Locking: Once an alert is triggered, the script "locks" itself briefly. This prevents the system from sending dozens of consecutive alerts for the same price movement, ensuring that you only receive one notification per trend shift.
  3. Dynamic Range: The script automatically calculates how many bars to analyze based on the timeframe you are currently viewing, ensuring it remains efficient and relevant to your specific chart settings.

In short, this tool acts as a "confluence" monitor—it waits for the 5, 15, 30, and 60-minute trends to all point in the same direction at once before notifying you of a potential major move.

Miscellaneous
It plays sound alertsIt issuies visual alerts to the screen
8 Views
0 Downloads
0 Favorites
Alert For ZZ SuperTrend's
//+------------------------------------------------------------------+
//|                                    Alert For ZZ SuperTrend's.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_chart_window

extern string SoundName = "email.wav";
extern int ShowDays   = 100;

int AlertIsAGo = 10;
double prevtime = 0, top = 8500000000, bot = 7700;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   int ShowBars = ((1440/Period())*ShowDays);
   if (ShowBars >= Bars) ShowBars = Bars - 50;

//---- indicator calculation

    for(int i=ShowBars; i>=0; i--)
     {
      if (prevtime != Time[0])
       { RefreshRates(); prevtime = Time[0]; AlertIsAGo = 0;
       }
       
       double AlwaysLookingUp = 0, AlwaysLookingDn = 0;
       
       double first2 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 5 MIN", 1,i);
       double secon2 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 15 MIN",1,i);
       double third2 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 30 MIN",1,i);
       double fourt2 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 60 MIN",1,i);
       
       double first21 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 5 MIN", 1,i+1);
       double secon21 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 15 MIN",1,i+1);
       double third21 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 30 MIN",1,i+1);
       double fourt21 = iCustom(Symbol(),0,"ZZ MTF Super_Trend 60 MIN",1,i+1);
      
      if (first2 > top && secon2 > top && third2 > top && fourt2 > top && fourt21 < top) AlwaysLookingUp = 10;
      if (first2 > top && secon2 > top && third2 > top && third21 < top && fourt2 > top) AlwaysLookingUp = 10;
      if (first2 > top && secon2 > top && secon21 < top && third2 > top && fourt2 > top) AlwaysLookingUp = 10;
      if (first2 > top && first21 < top && secon2 > top && fourt2 > top && fourt2 > top) AlwaysLookingUp = 10;
      
      if (first2 < bot && secon2 < bot && third2 < bot && fourt2 < bot && fourt21 > bot) AlwaysLookingDn = 10;
      if (first2 < bot && secon2 < bot && third2 < bot && third21 > bot && fourt2 < bot) AlwaysLookingDn = 10;
      if (first2 < bot && secon2 < bot && secon21 > bot && third2 < bot && fourt2 < bot) AlwaysLookingDn = 10;
      if (first2 < bot && first21 > bot && secon2 < bot && fourt2 < bot && fourt2 < bot) AlwaysLookingDn = 10;
      
     }
    
    if ( (AlertIsAGo <= 0) && (AlwaysLookingUp > 0) )
     { PlaySound(SoundName); AlertIsAGo = 10;
       Alert(" Up Up Up Up  ",Symbol());
     }
    if ( (AlertIsAGo <= 0) && (AlwaysLookingDn > 0) )
     { PlaySound(SoundName); AlertIsAGo = 10;
       Alert(" Dn Dn Dn Dn  ",Symbol());
     }
    
    
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments