FIBO_ZONE
Download scriptThis script is designed as a sophisticated analytical tool for the MetaTrader platform, primarily used to map out price behavior across different daily ranges and identify recurring patterns in how the market moves between specific price "zones."
Core Logic and Functionality
1. Dynamic Price Zone Mapping The tool works by analyzing the High, Low, and Close prices of previous trading days. It uses these values to calculate a central "pivot" point and then establishes five distinct horizontal boundaries (levels) above and below that center. These levels effectively divide the daily trading range into six unique price zones. Visually, these are represented on your chart as multi-colored lines, allowing you to see exactly where the market is currently positioned relative to historical volatility.
2. Automated Data Collection The script automatically scans back through historical data (based on a user-defined number of bars) to evaluate how the market behaved in previous sessions. It specifically looks at the relationship between the opening price and the closing price of each day, determining which "zone" the market started in and which zone it ended in.
3. Statistical Frequency Analysis The primary purpose of this logic is to provide a statistical breakdown of market behavior. Instead of just showing you lines, it performs a "probability check." It tracks every instance where a price moved from Zone A to Zone B and compiles this into a frequency table.
4. Performance Reporting Once the calculation is complete, the script generates a detailed report in the platform's log. This report provides:
- Opening Zone: Where the market typically begins its move.
- Closing Zone: Where the market frequently finishes its move.
- Precision Percentage: A statistical accuracy rate showing how often the market followed a specific path from one zone to another.
Summary for the User
Essentially, this tool transforms raw historical price action into a "probability map." Rather than guessing where the price might go, it uses historical data to tell you: "In the past, when the market opened in Zone X, it ended up in Zone Y a specific percentage of the time." It helps traders identify high-probability corridors and understand the prevailing "flow" of the market based on historical repetition.
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Crimson
#property indicator_color2 Sienna
#property indicator_color3 DarkSlateBlue
#property indicator_color4 DarkOliveGreen
#property indicator_color5 Green
extern int NumOfBars = 0;
extern int per = 10;
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
int init(){
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,Buffer1);
SetIndexBuffer(1,Buffer2);
SetIndexBuffer(2,Buffer3);
SetIndexBuffer(3,Buffer4);
SetIndexBuffer(4,Buffer5);
return(0);
}
int deinit(){
return(0);
}
int get_zone(double price,int shitf){
if(price>=Buffer1[shitf]) return (6);
else if(price<Buffer5[shitf]) return (1);
else if(price<Buffer1[shitf] && price>=Buffer2[shitf]) return (5);
else if(price<Buffer2[shitf] && price>=Buffer3[shitf]) return (4);
else if(price<Buffer3[shitf] && price>=Buffer4[shitf]) return (3);
else if(price<Buffer4[shitf] && price>=Buffer5[shitf]) return (2);
}
int last = 0;
int start() {
if(last == Bars) return (0);
last = Bars;
int limit = NumOfBars;
if(limit==0 || limit>Bars) limit=Bars;
int zone_stats[6][6];
int zone[6];
int b,l = 0;
double roc = 0;
double C,D,B,A,E;
for(int i = limit-1;i>=0;i--){
b = iBarShift(NULL,PERIOD_D1,Time[i]);
if(b!=l){
l = b;
int b_ = TimeDayOfWeek(Time[i]);
if(b_==1) b +=2; else b +=1;
double cl = iClose(NULL,PERIOD_D1,b);
double hi = iHigh(NULL,PERIOD_D1,b);
double lo = iLow(NULL,PERIOD_D1,b);
C = (cl+hi+lo) / 3;
D = C + (hi-lo)/2;
B = C - (hi-lo)/2;
E = C + (hi-lo);
A = C - (hi-lo);
Buffer1[i] = E;
Buffer2[i] = D;
Buffer3[i] = C;
Buffer4[i] = B;
Buffer5[i] = A;
int zo = get_zone(iOpen (NULL,PERIOD_D1,l),i)-1;
int zc = get_zone(iClose(NULL,PERIOD_D1,l),i)-1;
zone[zo]++;
zone_stats[zo][zc]++;
}
else{
Buffer1[i] = E;
Buffer2[i] = D;
Buffer3[i] = C;
Buffer4[i] = B;
Buffer5[i] = A;
}
}
for(i=0;i<6;i++){
for(int j=0;j<6;j++){
if(zone[i]!=0){
Print("OpenZone = " + (i+1) + ",CloseZone = "+(j+1)+", Prec = "+(MathAbs(zone_stats[i][j])/zone[i])*100);
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments