Author: Copyright � 2006, klot.
DT_ZZ

This script is a specialized technical analysis tool designed to identify and visualize specific price action patterns on a trading chart—specifically, "fractal" high and low points that occur within a defined range of historical data.

Core Logic Overview

The primary objective of this tool is to scan the market history to find significant structural turning points. It does this by constantly looking back over a user-defined period (the "Depth") to identify local peaks (highs) and valleys (lows). Instead of simply marking every high or low, the script applies a logical filter to ensure only the most prominent structural points are highlighted.

How it Processes Market Data

The logic operates through a three-step process:

1. Identifying Local Extremes The script moves backward through the price history. For every point in time, it calculates the highest high and the lowest low within the specified "Depth." It compares these current extremes against the previous ones it encountered.

2. Detecting Breakouts (Fractal Breaks) This is the core of the logic. The script looks for moments where the market breaks out of its previous structural boundaries:

  • For Lows: If the market creates a new low that is lower than the previous "last low," the script checks the position of the previous high. If the previous high occurred after the current low in time, it recognizes a specific structural shift and marks that point.
  • For Highs: Conversely, if the market creates a new high higher than the previous "last high," and the previous low was positioned after the current high, it triggers a similar marking logic for the upper boundary.

3. Dynamic Cleanup and Filtering To prevent the chart from becoming cluttered with every single price fluctuation, the script includes a specialized cleaning routine. When a significant structural point is confirmed:

  • It identifies the "strongest" point within that specific movement sequence.
  • It effectively "clears out" secondary or weaker points that were identified in that immediate area.
  • This ensures that only the most relevant peak or valley remains visible to the user, providing a cleaner view of the market's true trend structure.

Visual Output

The script translates this complex mathematical filtering into three distinct visual elements:

  • Trend Lines: It draws sections connecting significant price levels to show the flow of the market.
  • High Markers: Specific arrows or icons indicate where a confirmed structural high has occurred.
  • Low Markers: Specific arrows or icons indicate where a confirmed structural low has occurred.

Summary for the User

Essentially, this tool acts as an automated "filter" for price action. It ignores minor market noise and only highlights the significant structural "bones" of the chart by identifying when the market successfully breaks out of previous high/low zones, while automatically cleaning up any redundant data points to keep your workspace organized.

Miscellaneous
Implements a curve of type %1
7 Views
1 Downloads
0 Favorites
DT_ZZ
//+------------------------------------------------------------------+
//|                                                    DT_ZZ_nen.mq4 |
//|           Ìîäèôèöèðîâàë nen 11-1-2007                            |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, klot."
#property link      "klot@mail.ru"
#property link      "http://onix-trade.net/forum/index.php?s=&showtopic=4786&view=findpost&p=273797"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_width2 2
#property indicator_width3 2 

//---- indicator parameters
extern int ExtDepth=12;
extern int ExtLabel=0;
//---- indicator buffers
double zzL[];
double zzH[];
double zz[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
 //  IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexArrow(2,159);
//---- indicator buffers mapping
   SetIndexBuffer(0,zz);
   SetIndexBuffer(1,zzH);
   SetIndexBuffer(2,zzL);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
     
//---- indicator short name
   IndicatorShortName("DT_ZZ("+ExtDepth+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift,pos,lasthighpos,lastlowpos,curhighpos,curlowpos;
   double curlow,curhigh,lasthigh,lastlow;
   double min, max;
   ArrayInitialize(zz,0.0);
   ArrayInitialize(zzL,0.0);
   ArrayInitialize(zzH,0.0);
   
   lasthighpos=Bars; lastlowpos=Bars;
   lastlow=Low[Bars];lasthigh=High[Bars];
  for(shift=Bars-ExtDepth; shift>=0; shift--)
    {
      curlowpos=Lowest(NULL,0,MODE_LOW,ExtDepth,shift);
      curlow=Low[curlowpos];
      curhighpos=Highest(NULL,0,MODE_HIGH,ExtDepth,shift);
      curhigh=High[curhighpos];
      //------------------------------------------------
      if( curlow>=lastlow ) { lastlow=curlow; }
      else
         { 
            //èäåì âíèç
            if( lasthighpos>curlowpos  ) 
            { 
            zzL[curlowpos]=curlow;
              ///*
              min=100000; pos=lasthighpos;
              for(i=lasthighpos; i>=curlowpos; i--)
                 { 
                   if (zzL[i]==0.0) continue;
                   if (zzL[i]<min) { min=zzL[i]; pos=i; }
                   zz[i]=0.0;
                 } 
              zz[pos]=min;
              //*/
            } 
          lastlowpos=curlowpos;
          lastlow=curlow; 
         }
      //--- high
      if( curhigh<=lasthigh )  { lasthigh=curhigh;}
      else
         {  
            // èäåì ââåðõ
            if( lastlowpos>curhighpos ) 
            {  
            zzH[curhighpos]=curhigh;
           ///*
               max=-100000; pos=lastlowpos;
               for(i=lastlowpos; i>=curhighpos; i--)
                  { 
                    if (zzH[i]==0.0) continue;
                    if (zzH[i]>max) { max=zzH[i]; pos=i; }
                    zz[i]=0.0;
                  } 
               zz[pos]=max;
           //*/     
            }  
         lasthighpos=curhighpos;
         lasthigh=curhigh;    
         }       
    //----------------------------------------------------------------------
    }
 if (ExtLabel>0) Metka();

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


//--------------------------------------------------------
// Ðàññòàíîâêà ìåòîê. Íà÷àëî.
//--------------------------------------------------------
void Metka()
  {
   int metka=0; // =0 - äî ïåðâîãî ïåðåëîìà ZZ. =1 - èùåì ìåòêè ìàêñèìóìîâ. =2 - èùåì ìåòêè ìèíèìóìîâ.
   for(int shift=Bars-ExtDepth; shift>=0; shift--)
     {
      if (zz[shift]>0)
        {
         if (zzH[shift]>0)
           {
            metka=2; zzL[shift]=0; shift--;
           }
         else
           {
            metka=1; zzH[shift]=0; shift--;
           }
        }

      if (metka==0)
        {
         zzH[shift]=0; zzL[shift]=0;
        }
      else if (metka==1)
        {
         if (zzH[shift]>0) metka=0;
         zzL[shift]=0;
        }
      else if (metka==2)
        {
         if (zzL[shift]>0) metka=0;
         zzH[shift]=0;
        }
     }
  }
//--------------------------------------------------------
// Ðàññòàíîâêà ìåòîê. Êîíåö.
//--------------------------------------------------------

Comments