a_ZZ
Download scriptThis script is a technical analysis tool designed to identify key price levels and potential reversal points on a trading chart. It works by analyzing historical price action to map out significant structural boundaries, which it then uses to signal specific entry or exit opportunities.
The logic can be broken down into three primary stages:
1. Structural Analysis (Swing Identification)
The script begins by scanning the market history to identify "swings"—which are essentially the local highs and lows of the price action. Instead of just looking at every single candle, it evaluates a specific window of bars to determine if a price point is significant enough to be considered a turning point.
During this phase, the tool remembers these key points:
- Local Highs: These represent ceiling levels where the price peaked before pulling back.
- Local Lows: These represent floor levels where the price bottomed out before moving up.
2. Dynamic Level Mapping
Once these swing points are identified, the script creates a map of "Support" and "Resistance" levels. It doesn't just plot these once; it organizes them so that it can reference previous highs and lows relative to the current price.
The tool essentially builds a "memory" of where the price has historically struggled to break through (resistance) or where it has consistently found support (floors). It looks back across a large range of bars to ensure it captures the most relevant historical levels for the current market context.
3. Signal Generation
The final stage is where the tool provides visual cues on the chart based on the price's relationship with the mapped levels. It looks for specific "breakout" or "rejection" behaviors:
- Resistance Breakouts: The script monitors for instances where the price opens below a historical high but closes above it, indicating a potential upward move (marked with an upward arrow).
- Support Breakdowns: Conversely, it monitors for instances where the price opens above a historical low but closes below it, indicating a potential downward move (marked with a downward arrow).
To ensure clarity, the script includes logic to filter out repetitive signals, focusing on distinct movements rather than constant flickering. The goal is to highlight moments where the market overcomes a previous structural barrier, suggesting a shift in momentum or a new trend.
#property copyright "ANG3110@latchess.com"
//-------------ang_Amp_ZZ---------------
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 DimGray
#property indicator_color2 DimGray
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 Green
//--------------------------------
extern int cbars=1000;
extern int from=0;
extern int Length=10;
//---------------------------------
double ha[],la[],zz[],un[],dn[];
double hi,li,hm,lm,di,j;
int f,f1,ai,bi,aii,bii,f0,aibar,bibar;
//----------------------------------------------
int init() {
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,ha);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1,la);
SetIndexStyle(2,DRAW_SECTION,STYLE_SOLID,2);
SetIndexBuffer(2,zz);
SetIndexEmptyValue(2,0);
SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,2);
SetIndexBuffer(3,un);
SetIndexEmptyValue(3,0);
SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID,2);
SetIndexBuffer(4,dn);
SetIndexEmptyValue(4,0);
SetIndexArrow(4,234);
SetIndexArrow(3,233);
return(0);
}
//================================
int start() {
ArrayInitialize(zz,0);
ArrayInitialize(ha,0);
ArrayInitialize(la,0);
int shift,Swing,Swing_n,uzl,i,zu,zd,mv;
double LL,HH,BH,BL,NH,NL;
double Uzel[10000][3];
string text;
// loop from first bar to current bar (with shift=0)
Swing_n=0;Swing=0;uzl=0;
int barn = from + cbars;
BH =High[barn];BL=Low[barn];zu=barn;zd=barn;
for(shift=barn;shift>=from;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) {
Uzel[uzl][1]=zd;
Uzel[uzl][2]=BL;
}
if(Swing==-1) {
Uzel[uzl][1]=zu;
Uzel[uzl][2]=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;
}
for(i=1;i<=uzl;i++) {
//text=DoubleToStr(Uzel[i][1],0);
//text=;
mv=StrToInteger(DoubleToStr(Uzel[i][1],0));
zz[mv]=Uzel[i][2];
}
//--------------------------------
int dir = 0;
for(i=barn; i>=from; i--){
dn[i] = 0;
un[i] = 0;
ha[i]=zz[i];
la[i]=1000000;
for(int n=i+100; n>i; n--) {
if(zz[n]>ha[i]) ha[i] = zz[n];
if(zz[n]!=0 && la[i]>zz[n]) la[i]=zz[n];
}
//*
if(MathAbs(Close[i]-Open[i])>MathAbs(Close[i+1]-Open[i+1])){
if(Close[i]<la[i] && Open[i]>la[i]){
if(dir!=1){
dn[i] = la[i];
//dir = 1;
}
}
else if(Close[i]>ha[i] && Open[i]<ha[i]){
if(dir!=-1){
un[i] = ha[i];
//dir = -1;
}
}
}
//*/
}
//------------------------------------
return(0);
}
Comments