This tool is designed to help traders visualize the structural "skeleton" of a market by identifying key price swings and significant levels of support and resistance. Rather than showing every minor fluctuation, it filters out the market noise to highlight the most important turning points.
How the Logic Works
1. Trend Identification (The ZigZag Effect) The script scans the price history over a specific depth (defined by the user). It looks for significant peaks and valleys—points where the price reaches a new high or low relative to the surrounding area. When it detects a clear reversal in direction, it marks these points to create a "ZigZag" path. This allows traders to see the overall flow of the market: whether it is currently trending up, down, or moving sideways.
2. Identifying Key Extremes The logic doesn't just mark every high and low; it performs a comparison to ensure that a point is truly significant. For example, if the price moves up but then drops to a level lower than a previous low, the script recognizes this as a valid "low" point. It then updates the visual map to reflect this new structural change, ensuring the trend lines remain accurate to the most recent market behavior.
3. Support and Resistance Mapping Beyond just drawing the zigzag line, the script identifies static horizontal levels. These represent historical price points where the market has previously struggled to move past (resistance) or bounced off of (support).
- Support: Areas where the price previously hit a low and started moving upward.
- Resistance: Areas where the price previously hit a high and started moving downward.
4. Breakout Visualization One of the core features is the "Breakup" logic. When the price successfully moves beyond one of these established historical levels (breaking out of a previous "ceiling" or "floor"), the script helps visualize this transition. It projects these levels forward to help traders see where the "old" boundaries were and identify exactly when the market has broken into new territory.
Summary for Traders
By using this script, you can strip away the clutter of a busy chart. It provides a clear visual map of:
- The current major market structure (the ZigZag path).
- The historical boundaries where the price has reacted in the past.
- Real-time breakout signals, helping you identify when the market is shifting from one structural zone to another.
#property copyright "Copyright © 2006, klot."
#property link "klot@mail.ru" // added Support & Resistance at static levels by ArshadFX
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Aqua
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_color5 Red
//---- indicator parameters
extern int ExtDepth=12;
extern bool ShowBreakup =1; // Show Breakup of ZigZag static levels / Support Resistance
//---- indicator buffers
double zzL[], zzH[], zz[], UP[], DN[];
int init() // -------------- Custom indicator initialization function
{
SetIndexStyle(0,DRAW_SECTION); //---- drawing settings
SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,228);
SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,230);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(0,zz); //---- indicator buffers mapping
SetIndexBuffer(1,zzH);
SetIndexBuffer(2,zzL);
SetIndexBuffer(3,UP);
SetIndexBuffer(4,DN);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
SetIndexEmptyValue(3,0.0);
SetIndexEmptyValue(4,0.0);
IndicatorShortName("DT_ZZ("+ExtDepth+")");
return(0);
}
int start() // ----------------------------------- Main function call
{
int i,x,shift,pos,lasthighpos,lastlowpos,curhighpos,curlowpos;
double curlow,curhigh,lasthigh,lastlow, highS, lowS; // highS= HighStatic ...
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--) // loop of 12 block
{
curlowpos=Lowest(NULL,0,MODE_LOW,ExtDepth,shift); // lowest price of 12 block
curlow=Low[curlowpos]; // lowest bar index no
curhighpos=Highest(NULL,0,MODE_HIGH,ExtDepth,shift); // highest price of 12 block
curhigh=High[curhighpos]; // highest bar index no
//------------------------------------------------
if( curlow>=lastlow ) { lastlow=curlow; } // price is going up,
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; highS=max;
}
lastlowpos=curlowpos;
lastlow=curlow;
}
//--- high
if( curhigh<=lasthigh ) { lasthigh=curhigh;}
else
{// We go upwards
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; lowS=min;
}
lasthighpos=curhighpos;
lasthigh=curhigh;
}
// Added for displaying Breakups ------------- 17th of May, 2009
if (ShowBreakup)
{
for(x=lasthighpos; x>0; x--)
{
UP[x]=highS;
}
for(x=lastlowpos; x>0; x--)
{
DN[x]=lowS;
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments