DT-ZigZag-ATR_v1

Download script
Author: Copyright � 2005, klot
DT-ZigZag-ATR_v1

This script functions as a visual trading tool designed to identify specific price turning points and potential entry zones by combining two well-known market analysis concepts: the ZigZag pattern and ATR (Average True Range).

How it works

The logic follows a systematic three-step process to filter market noise and highlight significant price movements:

1. Identifying Structural Turning Points The script first scans the historical price data to find "peaks" and "valleys" using the standard ZigZag logic. Instead of looking at every minor price flicker, it focuses on major structural shifts. It searches backward through the chart to pinpoint exactly where a significant trend reversal occurred (the "ZigZag points").

2. Measuring Market Volatility Once a turning point is identified, the script calculates the Average True Range (ATR). In simple terms, this measures how much the price typically moves in a given timeframe. This allows the tool to understand the current "mood" of the market—whether it is moving calmly or experiencing high-intensity swings.

3. Plotting Dynamic Entry Zones Finally, the script places visual markers on the chart based on the relationship between the structural points and the volatility:

  • For Downward Trends: If a turning point is detected at a high price, the script calculates a specific distance below that point based on the current volatility (ATR). It then places a blue marker to highlight a potential area of interest.
  • For Upward Trends: If a turning point is detected at a low price, it performs a similar calculation above that point, placing a red marker to signal a potential reaction zone.

Summary for the Trader

Essentially, this tool doesn't just show you where the price was; it attempts to project where a price reaction might occur by looking at historical structure and current volatility. It automatically adjusts its markers based on how much the market is currently "breathing," helping to distinguish between meaningful structural reactions and insignificant price noise.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
DT-ZigZag-ATR_v1
//+------------------------------------------------------------------+ 
//| DT-ZigZag-ATR.mq4 | 
//+------------------------------------------------------------------+ 
#property copyright "Copyright © 2005, klot" 
#property link "klot@mail.ru" 

#property indicator_chart_window 
#property indicator_buffers 2 
#property indicator_color1 Red 
#property indicator_color2 Blue 
//---- input parameters 
extern int depth=12; 
extern int perATR=12; 
extern double k=2; 
//---- buffers 
double ExtMapBuffer1[]; 
double ExtMapBuffer2[]; 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function | 
//+------------------------------------------------------------------+ 
int init() 
{ 
//---- indicators 
SetIndexStyle(0,DRAW_ARROW); 
SetIndexBuffer(0,ExtMapBuffer1); 
SetIndexArrow(0,159); 
SetIndexStyle(1,DRAW_ARROW); 
SetIndexBuffer(1,ExtMapBuffer2); 
SetIndexArrow(1,159); 
//---- 
return(0); 
} 
//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function | 
//+------------------------------------------------------------------+ 
int deinit() 
{ 
//---- 

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

{ 
int limit, bigshift; 
int counted_bars=IndicatorCounted(); 
double zigzag1,atr1; 
//---- 
// if (counted_bars<0) return(-1); 

if (counted_bars>0) counted_bars--; 

limit=Bars-counted_bars+100; 

for (int i=limit; i>0; i--) 
{ 
for (int cnt=i; cnt<(100+i); cnt++) 
{ 
zigzag1=iCustom(NULL,0,"ZigZag",depth,5,3,0,cnt+1); 
if ( zigzag1!=0 ) break; 
} 

atr1=iATR(NULL,0,perATR,i); 

if ( iHigh(NULL,0,i+1)<=zigzag1 ) ExtMapBuffer2[i]=iLow(NULL,0,i)+k*atr1; else ExtMapBuffer2[i]=0.0; 
if ( iLow(NULL,0,i+1)>=zigzag1 ) ExtMapBuffer1[i]=iHigh(NULL,0,i)-k*atr1; else ExtMapBuffer1[i]=0.0; 

} 
Comment ("zigzag1 = ",zigzag1," limit = ",limit ); 
//---- 
return(0); 
} 
//+------------------------------------------------------------------+

Comments