DT-ZigZag_002

Author: klot
DT-ZigZag_002

This script is designed to enhance visual market analysis by synchronizing data from different timeframes onto a single trading chart. Its primary purpose is to allow traders to view high-level "ZigZag" price movements—which identify major structural trends and significant turning points—while looking at smaller, more detailed price intervals.

Core Functionality

The logic operates by acting as a bridge between two different views of the market. Normally, a standard ZigZag indicator only shows data relative to the timeframe you are currently viewing. This script changes that behavior by pulling "macro" data from a larger timeframe and projecting it accurately onto your current smaller timeframe chart.

How It Works

The logic follows a specific three-step process to ensure the information displayed is accurate:

  • Timeframe Synchronization: The script first looks at a primary "Gross Period" (a large timeframe like 1 hour or 4 hours). It gathers the historical price points from this larger view to identify major peaks and valleys.
  • Dynamic Mapping: Because smaller timeframes have many more candles than larger ones, the script performs a search through historical data. It calculates exactly where a specific moment on the small chart aligns with the corresponding moment on the large chart. This ensures that the "macro" price points stay perfectly aligned with the current time.
  • Visual Overlay: Once the alignment is calculated, the script pulls the ZigZag values from the larger timeframe and draws them as yellow markers on your current chart.

Key Benefits for the User

  • Contextual Awareness: It prevents "getting lost in the weeds" by highlighting whether the current small-scale price action is moving in harmony with a much larger trend.
  • Seamless Integration: You do not have to switch back and forth between different charts to see the bigger picture; the script automatically calculates the necessary offsets to show you the structural data you need instantly.
  • Visual Clarity: By using specific markers, it identifies significant price reversals that might be difficult to spot when only looking at minor price fluctuations.
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
DT-ZigZag_002
//+------------------------------------------------------------------+ 
//|                                                    DT-ZigZag.mq4 | 
//+------------------------------------------------------------------+ 
#property copyright "klot" 
#property link      "klot@mail.ru" 

#property indicator_chart_window 
#property indicator_buffers 1 
#property indicator_color1 Yellow 
//---- input parameters 
extern int GrossPeriod=60; 
extern int ExtDepth=12; 
extern int ExtDeviation=5; 
extern int ExtBackstep=3; 
//---- buffers 
double ExtMapBuffer1[]; 
datetime daytimes[]; 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
//---- indicators 
   SetIndexStyle(0,DRAW_ARROW); 
   SetIndexArrow(0,159); 
   SetIndexBuffer(0,ExtMapBuffer1); 
   SetIndexEmptyValue(0,0.0); 
//---- 
   if (Period()>GrossPeriod) { Alert("DT-ZigZag:  ", GrossPeriod); return(0); } 
   // Âñå Time[] ñåðèè âðåìåíè îòñîðòèðîâàíî â íàïðàâëåíèè óáûâàíèÿ 
   ArrayCopySeries(daytimes,MODE_TIME,Symbol(),GrossPeriod); 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 
//---- 
    
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
  { 
   int    limit, bigshift; 
   int    counted_bars=IndicatorCounted(); 
//---- 
   if (counted_bars<0) return(-1); 
    
   if (counted_bars>0) counted_bars--; 
    
   limit=Bars-counted_bars; 
    
   for (int i=0; i<limit; i++) 
   { 
   if(Time[i]>=daytimes[0]) bigshift=0; 
   else 
     { 
      bigshift = ArrayBsearch(daytimes,Time[i-1],WHOLE_ARRAY,0,MODE_DESCEND); 
      if(Period()<=GrossPeriod) bigshift++; 
     } 
  ExtMapBuffer1[i]=iCustom(NULL,GrossPeriod,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,bigshift); 
   } 
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+

Comments