This script is an automated technical analysis tool designed to identify and visualize significant price "zones" or "levels" on a financial chart. Rather than following standard moving averages or oscillators, it focuses on identifying structural price boundaries based on the history of the asset.
Core Logic Overview
The script functions by scanning historical price data to map out specific price points where significant movement occurred. It treats the market as a series of "steps," identifying areas where the price broke out and established new highs or lows.
1. Structural Mapping (The "Scanning" Phase)
The script begins by performing a deep scan of all available historical candles. It looks for instances where the price significantly exceeded a preceding level.
- Identifying Highs: If the price reaches a point higher than the previous established level plus a user-defined distance (the "Box Size"), the script recognizes this as a new upward boundary.
- Identifying Lows: Conversely, if the price drops below an established level by that same distance, it marks it as a new downward boundary.
By doing this, the script creates a backbone of price levels, essentially identifying where the market "settled" or "rejected" during its history.
2. Visual Representation (The "Drawing" Phase)
Once these levels are identified, the script draws visual elements on your chart:
- Rectangles: It places rectangular boxes at these established price levels. These act as visual cues for support and resistance.
- Color Coding: It differentiates between upward movements (often highlighted in Aqua or Blue tones) and downward movements (highlighted in Red or Yellow tones). These boxes help the user see at a glance where the market has historically reacted to specific prices.
3. Signal Generation (The "Alert" Phase)
The most advanced part of the logic is how it interprets these rectangles to generate actionable signals. It compares the most recent established price levels against previous ones to determine market momentum:
- Buy Signals: The script looks for specific sequences where current resistance levels are being broken or validated in a way that suggests upward momentum. If the mathematical relationship between the last two "High" levels meets its criteria, it triggers a Buy alert.
- Sell Signals: Similarly, it monitors the relationship between "Low" price boundaries. When the price action confirms a breakdown or a reversal at these levels, it triggers a Sell alert.
4. User Notifications
To ensure the trader doesn't have to watch the screen constantly, the script includes an automated alert system. When the logic confirms a specific trade setup (Buy or Sell), it generates a pop-up notification on the platform. It is also programmed to limit these alerts (e.g., repeating only a few times) to avoid "alert fatigue" during high-volatility periods.
Summary for the Trader
In simple terms, this script acts like an automated surveyor. It looks back at the history of the chart, marks every important "floor" and "ceiling" it finds, and then watches the current price live. When the current price interacts with these historical boundaries in a specific pattern, it signals whether the market is likely to continue its trend or reverse.
//+------------------------------------------------------------------+
//| X_O_serg153xo.mq4 |
//| Copyright © 2005, Serg153 |
//| "" |
//| ïåðåäåëêà 04_2008 ver1 Aleksandr Pak, Alma-Ata, 03.2008 |
//| ekr-ap@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Serg153"
#property link ""
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
extern color ColorUp = Aqua; // Öâåò "êðåñòèêà"
extern color ColorDown = DarkGoldenrod; // Öâåò "íîëèêà"
//---- input parameters
extern int RazmBox = 20;
extern int count_Alert=3; //÷èñëî ïîâòîðåíèé Àëåðò
//----
int i, p, Lt, Lt1, Tb;
double RazmBoXO, Cnac;
int VsegoBarov;
double up[],down[];
int first=0,count_a=0;
double ftime;
string s;
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,up);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,217);
SetIndexBuffer(1,down);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,218);
int tf=Period();
if(tf>30) s=Symbol()+" H"+tf/60; else s=Symbol()+" M"+tf;
return (0);
}
int deinit()
{
for(i = 0; i <= Lt1; i++)
{
ObjectDelete("BodyXO" + i);
ObjectDelete("BodyX" + i);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Êðåñòèêè Íîëèêè |
//+------------------------------------------------------------------+
int start()
{
if(ftime!=Time[0]) count_a=0;
RazmBoXO = RazmBox*Point;
VsegoBarov = Bars - 1 ;
Lt = 0;
Cnac = Open[VsegoBarov];
Tb = 0;
p = 0;
// 1 ïðîãîí ïîäñ÷¸ò âñåõ áàðîâ
for(i = VsegoBarov; i >= 1; i--)
{
p = 0;
while(High[i] >= Cnac + RazmBoXO)
{
if(Tb == 0)
Lt++;
Cnac += RazmBoXO;
p++;
Tb = 1;
}
if(p > 0)
continue;
while(Low[i] <= Cnac - RazmBoXO)
{
if(Tb == 1)
Lt++;
Cnac -= RazmBoXO; Tb=0;
}
}
Lt = 10 + Lt*2;
// ñäâèãàåì âñå áàðû âïðàâî
// 2 ïðîãîí ðàçðèñîâêà ãðàôèêà
Cnac = Open[VsegoBarov];
Lt1 = 0;
for(i = VsegoBarov; i >= 1; i--)
{
p = 0;
while (High[i] >= Cnac + RazmBoXO)
{
if(Tb == 0)
Lt -= 2;
Lt1++;
ObjectCreate("BodyXO" + Lt1, OBJ_RECTANGLE, 0, 0, 0, 0, 0);
ObjectSet("BodyXO" + Lt1, OBJPROP_TIME1, Time[Lt]);
ObjectSet("BodyXO" + Lt1, OBJPROP_PRICE1, Cnac);
ObjectSet("BodyXO" + Lt1, OBJPROP_TIME2, Time[Lt-2]);
ObjectSet("BodyXO" + Lt1, OBJPROP_PRICE2, Cnac + RazmBoXO);
ObjectSet("BodyXO" + Lt1, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("BodyXO" + Lt1, OBJPROP_BACK, False);
ObjectSet("BodyXO" + Lt1, OBJPROP_COLOR, ColorUp);
ObjectCreate("BodyX" + Lt1, OBJ_RECTANGLE, 0, 0, 0, 0, 0);
ObjectSet("BodyX" + Lt1, OBJPROP_TIME1, Time[Lt]);
ObjectSet("BodyX" + Lt1, OBJPROP_PRICE1, Cnac);
ObjectSet("BodyX" + Lt1, OBJPROP_TIME2, Time[Lt-2]);
ObjectSet("BodyX" + Lt1, OBJPROP_PRICE2, Cnac + RazmBoXO);
ObjectSet("BodyX" + Lt1, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("BodyX" + Lt1, OBJPROP_BACK, False);
ObjectSet("BodyX" + Lt1, OBJPROP_COLOR, Blue);
Cnac += RazmBoXO;
Tb = 1;
p++;
}
if(p > 0)
continue;
while(Low[i] <= Cnac - RazmBoXO)
{
if(Tb == 1)
Lt -= 2;
Lt1++;
ObjectCreate("BodyXO" + Lt1, OBJ_RECTANGLE, 0, 0, 0, 0, 0);
ObjectSet("BodyXO" + Lt1, OBJPROP_TIME1, Time[Lt]);
ObjectSet("BodyXO" + Lt1, OBJPROP_PRICE1, Cnac);
ObjectSet("BodyXO" + Lt1, OBJPROP_TIME2, Time[Lt-2]);
ObjectSet("BodyXO" + Lt1, OBJPROP_PRICE2, Cnac - RazmBoXO);
ObjectSet("BodyXO" + Lt1, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("BodyXO" + Lt1, OBJPROP_BACK, True);
ObjectSet("BodyXO" + Lt1, OBJPROP_COLOR, ColorDown);
ObjectCreate("BodyX" + Lt1, OBJ_RECTANGLE, 0, 0, 0, 0, 0);
ObjectSet("BodyX" + Lt1, OBJPROP_TIME1, Time[Lt]);
ObjectSet("BodyX" + Lt1, OBJPROP_PRICE1, Cnac);
ObjectSet("BodyX" + Lt1, OBJPROP_TIME2, Time[Lt-2]);
ObjectSet("BodyX" + Lt1, OBJPROP_PRICE2, Cnac - RazmBoXO);
ObjectSet("BodyX" + Lt1, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("BodyX" + Lt1, OBJPROP_BACK, False);
ObjectSet("BodyX" + Lt1, OBJPROP_COLOR, Yellow);
Cnac -= RazmBoXO;
Tb = 0;
}
}
//*******************************Îïðåäåëåíèå òîðãîâûõ ñèãíàëîâ********************************************
int Lbd=Lt1; //last restanle
double last=ObjectGet("BodyX" + Lbd, OBJPROP_TIME2);
for(i=Lt1; i>0;i--)
{if(last!=ObjectGet("BodyX" + i, OBJPROP_TIME2)) break;
}
int Lbd2=i+1;
int Pbd=i;
last=ObjectGet("BodyX" + Pbd, OBJPROP_TIME2);
for(i=Pbd; i>0;i--)
{if(last!=ObjectGet("BodyX" + i, OBJPROP_TIME2)) break;
}
int Pbd2=i+1;
int z;
int ik2=iBarShift(NULL,0,ObjectGet("BodyX" + Lbd,OBJPROP_TIME2),FALSE);
double price_L0=ObjectGet("BodyX" + Lbd, OBJPROP_PRICE2);
double price_L1=ObjectGet("BodyX" + Lbd2, OBJPROP_PRICE1);
double price_P0=ObjectGet("BodyX" + Pbd, OBJPROP_PRICE2);
double price_P1=ObjectGet("BodyX" + Pbd2, OBJPROP_PRICE1);
int cL,cP;
if(price_L0>price_L1) cL=0; else cL=1;
if(price_P0>price_P1) cP=0; else cP=1;
if(cL==1&&cP==1){down[0]=High[0]+ 25*Point; c_alert(1);}
if(cL==1&&cP==0&&price_L0<price_P1){down[0]=High[0]+ 25*Point;c_alert(1);}
if(cL==0&&cP==0){up[0]=Low[0]- 25*Point; c_alert(0);}
if(cL==0&&cP==1&&price_L0>price_P1){up[0]=Low[0]- 25*Point; c_alert(0);}
return(0);
}
//+------------------------------------------------------------------+
void c_alert(int w)
{
ftime=Time[0];
if(count_a<count_Alert)
{count_a+=1;
if(w==0) Alert(s," Õ-Î BUY"); else Alert( s," X-O SELL");
}
}
Comments