ZigZag33
Download scriptThis script is a technical analysis tool designed for the MetaTrader 4 platform. Its primary purpose is to identify and visualize significant price boundaries on a trading chart by establishing "blocks" of price action. Instead of just looking at individual price points, it evaluates the range of movement within specific periods to determine where the market is establishing structural highs and lows.
Core Logic and Behavior
The indicator operates based on a user-defined "Box Size." This parameter defines the minimum vertical distance required for the tool to recognize a significant move. If the market moves more than this specified distance, the script treats that movement as a potential new structural boundary.
Here is how the logic processes the market data:
- Dynamic Range Detection: The tool continuously scans historical price data (Highs and Lows). It looks for moments where the distance between the highest and lowest price exceeds your defined box size.
- Trend Identification: When a significant move is detected, the script determines whether it is an upward or downward expansion.
- If the price pushes significantly higher than previous levels, it identifies a new "High" boundary.
- If the price pushes significantly lower than previous levels, it identifies a new "Low" boundary.
- Boundary Maintenance: The script also monitors "consolidation" periods—times when the price is moving within a small range. If the price stays within these boundaries but touches or exceeds the previous high or low, the indicator updates the structural limits to reflect the new reality of the market's reach.
- Visual Feedback: The tool identifies specific "turning points" where the market trend switches direction (for example, moving from a series of higher highs to a lower low). It then plots these key levels on your chart as visual markers.
Key Takeaways for the User
Essentially, this script acts as a filter to remove "market noise." By using the Box Size logic, it ignores minor price fluctuations and only highlights major structural shifts. This allows you to see the significant "ceilings" and "floors" of the market, helping you identify where price has historically struggled to break through or where it has decisively pushed into new territory.
// ÇèãÇàã.mq4
// Èíäèêàòîð ÇèãÇàã â ñòèëå Ðåíêî è Êðåñòèêè-Íîëèêè
#property copyright "mandorr@gmail.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Violet
#property indicator_width1 1
#property indicator_style1 0
extern int BoxSize=50; // Ðàçìåð êèðïè÷à â ïèïñàõ
double buffer0[];
int MySize;
double size;
void init() {
int MinStop;
MinStop=MarketInfo(Symbol(),MODE_STOPLEVEL);
MySize=BoxSize; if (MySize<MinStop && MinStop>0) {MySize=MinStop;}
size=MySize*Point;
SetIndexStyle (0,DRAW_SECTION);
SetIndexBuffer(0,buffer0);
SetIndexLabel (0,"Çíà÷åíèå");
SetIndexDrawBegin(0,0);
IndicatorShortName("ÇèãÇàã ("+MySize+" ïèïñîâ)");
}
void deinit() {
}
void start() {
int count, d, d1, i, h_shift, l_shift;
double h, l, H, L;
count=Bars-1;
d=0;
h=(High[count]+Low[count]+size)/2;
l=(High[count]+Low[count]-size)/2;
h_shift=count;
l_shift=count;
buffer0[count]=EMPTY_VALUE;
for (i=count-1; i>=0; i--) {
d1=d;
H=High[i];
L=Low [i];
if (H-L>size) {
if (H-h>=l-L) {d= 1; h=H; l=h-size; h_shift=i;}
else {d=-1; l=L; h=l+size; l_shift=i;}
}
else {
if (H>h && L>=l) {d= 1; h=H; l=h-size; h_shift=i;}
if (L<l && H<=h) {d=-1; l=L; h=l+size; l_shift=i;}
}
H=High[h_shift];
L=Low [l_shift];
if (d>0 && d1<0) {buffer0[l_shift]=L;}
if (d<0 && d1>0) {buffer0[h_shift]=H;}
}
H=High[h_shift];
L=Low [l_shift];
if (d>0) {buffer0[h_shift]=H;}
if (d<0) {buffer0[l_shift]=L;}
}
Comments