ZZZ
Download scriptThis script functions as a specialized technical analysis tool designed to identify and map significant price結構 (structures) on a trading chart. Its primary purpose is to filter out minor market "noise" to highlight the most prominent highs and lows within a specific timeframe.
Core Logic Overview
The tool works by scanning historical price data to identify "Swing Points"—moments where the price reaches a local peak or valley relative to the surrounding candles. Instead of marking every tiny fluctuation, it uses a defined "Length" parameter to look back at a group of candles simultaneously to determine if a specific point is significant enough to be considered a major turning point.
How it Processes the Market
The script follows a systematic three-step logic to visualize these points:
-
Trend Detection: The tool constantly evaluates whether the current price movement is trending upwards, downwards, or experiencing a reversal. It compares the current high and low values against the preceding candles to establish the "swing" direction.
-
Peak and Valley Identification:
- Highs: When the script detects an upward swing that eventually reaches a turning point, it captures the highest price reached during that move.
- Lows: Conversely, when it identifies a downward swing, it captures the lowest price reached before the momentum shifts.
-
Data Mapping: Once a significant peak or valley is confirmed (meaning the price has moved enough to prove that the previous point was indeed a "swing"), the script places a visual marker on the chart. It specifically tracks:
- Resistance Levels: Marking the top of upward price moves.
- Support Levels: Marking the bottom of downward price moves.
Summary for the User
Essentially, this tool acts as an automated "structuralist." It ignores the minor zig-zags of the market and instead draws a map of the significant structural boundaries. By highlighting these key highs and lows, it helps traders visualize the prevailing market structure, making it easier to see where the price has historically struggled to break through or where it has found solid footing.
//+------------------------------------------------------------------+
//| ZZZ.mq4 |
//+------------------------------------------------------------------+
#property copyright "Istoniz"
#property link "http://www.kg/"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Aqua
//---- input parameters
extern int Length=6;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_SECTION);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int barn=300;
/*
//--------------------------
int counted_bars=IndicatorCounted();
limit,barn=Bars-Length;
if (counted_bars<0) return(-1);
if (counted_bars>0) counted_bars--;
limit=Bars-counted_bars+4*Length;
//Comment(" limit = ",limit, " Bars = ",Bars);
//--------------------------
*/
//--------------------------
int shift,Swing,Swing_n,i,zu,zd,uzl;
double LL,HH,BH,BL,NH,NL;
Swing_n=0; Swing=0; uzl=0;
BH =High[barn]; BL=Low[barn];
zu=barn; zd=barn;
for ( shift=barn; shift>0 ; shift--)
{
LL=10000000; HH=-100000000;
for ( i=shift+Length; i>shift+1 ; i--)
{
if ( Low[i]<LL ) LL=Low[i];
if ( High[i]>HH ) HH=High[i];
}
if ( Low[shift]<LL && High[shift]>HH )
{
Swing=2;
if ( Swing_n==1 ) zu=shift+1;
if ( Swing_n==-1 ) zd=shift+1;
} else
{
if ( Low[shift]<LL ) Swing=-1;
if ( High[shift]>HH ) Swing=1;
}
if ( Swing!=Swing_n && Swing_n!=0 )
{
if ( Swing==2 )
{
Swing=-Swing_n;
BH=High[shift];
BL=Low[shift];
}
uzl=uzl+1;
if ( Swing==1 )
{
ExtMapBuffer1[zd]=BL;
}
if ( Swing==-1 )
{
ExtMapBuffer1[zu]=BH;
}
BH=High[shift];
BL=Low[shift];
}
if ( Swing==1 )
{
if ( High[shift]>=BH )
{
BH=High[shift];
zu=shift;
}
}
if ( Swing==-1 )
{
if ( Low[shift]<=BL )
{
BL=Low[shift];
zd=shift;
}
}
Swing_n=Swing;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments