5_ZZ_Semafor

Download script
Author: Copyright � 2009, Serg73, TradeProgrammer
5_ZZ_Semafor

The 5_ZZ_Semafor is a specialized technical analysis tool designed to help traders identify significant price turning points and trend reversals. Rather than providing a simple moving average or a basic price line, this script acts as a visual "semaphore"—a signaling system that highlights critical structural shifts in the market by layering multiple different types of "ZigZag" data.

Core Logic Overview

The primary objective of this tool is to filter out market noise and focus on high-probability reversals. It achieves this by simultaneously calculating five different ZigZag periods. Each period represents a different timeframe of price action:

  • Short-termer periods (e.g., 7) capture minor fluctuations.
  • Medium-termer periods (e.g., 12, 25) identify the general flow of the current trend.
  • Long-termer periods (e.g., 50, 100) reveal the major structural cycles of the market.

How the Filtering Works

The script follows a strict hierarchy of priority to ensure that your chart remains clean and readable. It processes these five different timeframes from the smallest to the largest in a "nested" logic:

  1. Priority Ranking: The tool looks for price reversals starting from the shortest period. However, if it detects a larger, more significant reversal from a higher-priority period (like a 50 or 100 period), it will automatically prioritize that signal over the smaller ones.
  2. Signal Suppression: To prevent visual clutter, the script employs a "suppression" logic. If a major structural change is detected by one of the larger periods, the tool hides the signals from the smaller periods at that specific price point. This ensures that you only see the most significant "peaks" and "valleys" relevant to your desired trading style.
  3. Visual Representation: The results are displayed on your chart as distinct arrow markers. These arrows indicate where the market has reached a peak or a trough based on the combined data of all five periods.

User Experience & Application

By using this script, you can customize which levels of market structure you wish to see by adjusting the "Row Count." Depending on your trading style:

  • Scalpers might focus on the smaller period settings to catch quick moves.
  • Swing Traders will find value in the larger period settings, as the tool will automatically prioritize these major structural anchors while suppressing the "jitter" of minor price movements.

In essence, the 5_ZZ_Semafor acts as a sophisticated filter that organizes complex market data into clear, prioritized visual signals, helping you identify where a trend is likely to end or begin.

Miscellaneous
Implements a curve of type %1
7 Views
0 Downloads
0 Favorites
5_ZZ_Semafor
//+------------------------------------------------------------------+
//|                                                 5_ZZ_Semafor.mq4 |
//|           Copyright © 2009, Asystem2000, Serg73, TradeProgrammer |
//|                        http://tradeprogrammer.narod.ru/index.htm |
//|                                 mailto:TradeProgrammer@yandex.ru |
//+------------------------------------------------------------------+
#define IND "ZZ_i"

#property copyright "Copyright © 2009, Serg73, TradeProgrammer"
#property link      "www.http://tradeprogrammer.narod.ru/index.htm"
#property link      "mailto:TradeProgrammer@yandex.ru"


#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Pink
#property indicator_color2 Chocolate
#property indicator_color3 Gold
#property indicator_color4 DodgerBlue
#property indicator_color5 LimeGreen

#property indicator_width1 0
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 3
#property indicator_width5 4


//---- input parameters

extern int       DrowCount=5;       // êîëè÷åñòâî îòîáðàæàåìûõ çèãçàãîâ
extern int       ZZ_1_Period=7;     // ïàðàìåòðû êàæäîãî çèãçàãà
extern int       ZZ_1_Reverse=0;
extern int       ZZ_2_Period=12;
extern int       ZZ_2_Reverse=0;
extern int       ZZ_3_Period=25;
extern int       ZZ_3_Reverse=0;
extern int       ZZ_4_Period=50;
extern int       ZZ_4_Reverse=0;
extern int       ZZ_5_Period=100;
extern int       ZZ_5_Reverse=0;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];


double z;
int j,cnt;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,140);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,141);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,142);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,143);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4,144);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexEmptyValue(4,0.0);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){

         int limit=Bars-IndicatorCounted();

            for(int i=limit-1;i>=0;i--){
                  for(j=i,cnt=0;j<Bars && cnt<2;j++){
                     ExtMapBuffer1[j]=0;
                     z=iCustom(NULL,0,IND,ZZ_1_Period,ZZ_1_Reverse,0,j);
                        if(z!=0){
                           ExtMapBuffer1[j]=z;
                           cnt++;
                        }
                  }
                  if(DrowCount<2)continue;
                  for(j=i,cnt=0;j<Bars && cnt<2;j++){
                     ExtMapBuffer2[j]=0;
                     z=iCustom(NULL,0,IND,ZZ_2_Period,ZZ_2_Reverse,0,j);
                        if(z!=0){
                           ExtMapBuffer2[j]=z;
                           ExtMapBuffer1[j]=0;
                           cnt++;
                        }
                  }  
                  if(DrowCount<3)continue;  
                  for(j=i,cnt=0;j<Bars && cnt<2;j++){
                     ExtMapBuffer3[j]=0;
                     z=iCustom(NULL,0,IND,ZZ_3_Period,ZZ_3_Reverse,0,j);
                        if(z!=0){
                           ExtMapBuffer3[j]=z;
                           ExtMapBuffer2[j]=0;
                           ExtMapBuffer1[j]=0;                           
                           cnt++;
                        }
                  }     
                  if(DrowCount<4)continue;
                  for(j=i,cnt=0;j<Bars && cnt<2;j++){
                     ExtMapBuffer4[j]=0;
                     z=iCustom(NULL,0,IND,ZZ_4_Period,ZZ_4_Reverse,0,j);
                        if(z!=0){
                           ExtMapBuffer4[j]=z;
                           ExtMapBuffer3[j]=0;
                           ExtMapBuffer2[j]=0;
                           ExtMapBuffer1[j]=0;                           
                           cnt++;
                        }
                  }      
                  if(DrowCount<5)continue; 
                  for(j=i,cnt=0;j<Bars && cnt<2;j++){
                     ExtMapBuffer5[j]=0;
                     z=iCustom(NULL,0,IND,ZZ_5_Period,ZZ_5_Reverse,0,j);
                        if(z!=0){
                           ExtMapBuffer5[j]=z;
                           ExtMapBuffer4[j]=0;
                           ExtMapBuffer3[j]=0;
                           ExtMapBuffer2[j]=0;
                           ExtMapBuffer1[j]=0;                                                      
                           cnt++;

                        }
                  }      
                              
            }

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

Comments