X_O_serg153xo
Download scriptThis script is a custom technical analysis tool designed for the MetaTrader platform to visualize specific price movements and "zones" on a trading chart. Instead of relying on standard moving averages or oscillators, it uses a geometric approach to identify and draw rectangular areas based on price boundaries.
Core Logic and Functionality
1. Price Boundary Detection The script scans the historical price data starting from the very beginning of the available chart. It looks for instances where the high or low prices of specific candles exceed a predefined distance (the "Size Box"). By tracking these peaks and valleys, the tool identifies significant price shifts rather than just small fluctuations.
2. Dynamic Zone Calculation The logic operates on a cumulative calculation method. As it moves through history:
- If it detects a price movement reaching upward beyond a certain threshold, it establishes a boundary and "steps" forward by the defined size.
- If it detects a downward movement, it establishes a lower boundary and "steps" backward.
- This creates a chain of linked price zones that map out how the market has moved over time.
3. Visual Mapping (The Graphics) Once the script identifies these zones, it automatically draws two types of visual elements on your chart:
- Primary Zones: These are colored rectangles (using user-defined colors for "Up" and "Down" movements) that highlight the price areas where significant activity occurred.
- Secondary Indicators: The script also generates blue secondary rectangles to provide an additional layer of visual depth, helping to differentiate between background zones and active price areas.
4. Visual Organization The tool is designed to keep the chart clean and organized:
- Dynamic Positioning: It calculates the correct timing and pricing for each rectangle so they appear in the correct chronological order.
- Automatic Cleanup: The script includes a "deinitialization" feature, meaning that if you remove the indicator from the chart, it automatically wipes away all the drawn boxes, preventing the chart from remaining cluttered with old data.
Summary for the Trader
In simple terms, this script acts as an automated "map maker." It analyzes where the price has pushed most aggressively in the past and draws visible blocks on your screen to represent those zones. This allows you to see at a glance which price levels have historically been significant without having to manually measure distances or guess at support and resistance levels.
//+------------------------------------------------------------------+
//| X_O_serg153xo.mq4 |
//| Copyright © 2005, Serg153 |
//| "" |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Serg153"
#property link ""
//----
#property indicator_chart_window
extern color ColorUp = Red; // Öâåò "êðåñòèêà"
extern color ColorDown = Yellow; // Öâåò "íîëèêà"
//---- input parameters
extern int RazmBox = 20;
//----
int i, p, Lt, Lt1, Tb;
double RazmBoXO, Cnac;
int VsegoBarov;
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
for(i = 0; i < 99999; i++)
{
ObjectDelete("BodyXO" + i);
ObjectDelete("BodyX" + i);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Êðåñòèêè Íîëèêè |
//+------------------------------------------------------------------+
int start()
{
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, Blue);
Cnac -= RazmBoXO;
Tb = 0;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments