^X_Fibo-v1.1

Download script
^X_Fibo-v1.1

This script is designed to automate the placement of key technical analysis levels on your trading chart, specifically focusing on historical price action and Fibonacci retracement zones. It eliminates the need for manual drawing by automatically identifying significant price points from previous periods and projecting them forward.

Core Functionality

1. Dynamic Timeframe Adaptation The script includes an automation feature that intelligently adjusts its behavior based on the timeframe you are currently viewing. If automation is enabled, it detects whether you are looking at small, medium, or large timeframes (such as Hourly, Daily, or Weekly) and selects the most appropriate data set to calculate the levels. This ensures that the technical levels remain relevant regardless of how zoomed in or out your chart is.

2. Historical Data Analysis The logic works by analyzing the price action of the previous completed period. It specifically identifies three critical data points:

  • The highest price reached (High)
  • The lowest price reached (Low)
  • The closing price (Close)

By calculating the difference between the High and the Low, the script determines the "range" or volatility of that previous session.

3. Automated Visual Mapping Once the script identifies these values, it automatically draws several types of visual aids on your chart:

  • Boundary Lines: It places horizontal lines at the exact High and Low levels of the previous period to act as clear visual boundaries for current price action.
  • Fibonacci Projections (Upper & Lower): The script projects Fibonacci retracement levels based on the previous range. These are extended upwards and downwards, creating a "map" of potential support and resistance zones.
  • Retracement Zones: It creates specific overlapping zones to help traders identify where the price might stall or reverse as it pulls back from its previous highs or lows.

How it Benefits the User

Instead of a trader having to manually calculate ranges and draw dozens of Fibonacci lines every time a new day or week begins, this script performs those calculations instantly. It anchors these levels to the current candle, providing an immediate visual representation of "Supply" and "Demand" zones based on the most recent completed price data. When you switch charts or timeframes, the script resets and redraws these levels automatically to keep your technical analysis consistent.

14 Views
0 Downloads
0 Favorites
^X_Fibo-v1.1
#property indicator_chart_window
extern color colorline=Green;
extern bool _Automate = true;
extern string _My_Period_Data = "1440=D1; 10080=W1; 43200=MN";
extern int _My_Period = PERIOD_W1;
int _N_Time, _Cur_Period;
//-------------------------------------------------------------------------------------------
int init() {

if(!_Automate) {
if(Period() > _My_Period) {
Comment("\n\n                    ERROR - CHART PERIOD IS TOO GREAT!");
return(-1); // then exit
}} else {
if(Period() > PERIOD_H4) _My_Period = PERIOD_MN1;
else if(Period() < PERIOD_H4) _My_Period = PERIOD_D1;
else _My_Period = PERIOD_W1;
}

ObjectCreate ("TOP", OBJ_HLINE, 0, Time[0], 0);
ObjectSet    ("TOP", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet    ("TOP", OBJPROP_WIDTH, 1);
ObjectSet    ("TOP", OBJPROP_COLOR, Orange);

ObjectCreate ("FU", OBJ_FIBO, 0, Time[89], 0, Time[89], 0);
ObjectSet    ("FU", OBJPROP_LEVELSTYLE, STYLE_DASH);
ObjectSet    ("FU", OBJPROP_LEVELWIDTH, 1);
ObjectSet    ("FU", OBJPROP_LEVELCOLOR, Orange);
ObjectSet    ("FU", OBJPROP_FIBOLEVELS, 10);
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+0, 0.236);
ObjectSetFiboDescription("FU",0,"+23.6     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+1, 0.382);
ObjectSetFiboDescription("FU",1,"+38.2     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+2, 0.5);
ObjectSetFiboDescription("FU",2,"+50.0     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+3, 0.618);
ObjectSetFiboDescription("FU",3,"+61.8     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+4, 0.764);
ObjectSetFiboDescription("FU",4,"+76.4     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+5, 1.0);
ObjectSetFiboDescription("FU",5,"+100.0     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+6, 1.236);
ObjectSetFiboDescription("FU",6,"+123.6     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+7, 1.382);
ObjectSetFiboDescription("FU",7,"+138.2     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+8, 1.5);
ObjectSetFiboDescription("FU",8,"+150.0     ");
ObjectSet    ("FU", OBJPROP_FIRSTLEVEL+9, 1.618);
ObjectSetFiboDescription("FU",9,"+161.8     ");

ObjectCreate ("BOTTOM", OBJ_HLINE, 0, Time[0], 0);
ObjectSet    ("BOTTOM", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet    ("BOTTOM", OBJPROP_WIDTH, 1);
ObjectSet    ("BOTTOM", OBJPROP_COLOR, DeepSkyBlue);

ObjectCreate ("FD", OBJ_FIBO, 0, Time[89], 0, Time[89], 0);
ObjectSet    ("FD", OBJPROP_LEVELSTYLE, STYLE_DASH);
ObjectSet    ("FD", OBJPROP_LEVELWIDTH, 1);
ObjectSet    ("FD", OBJPROP_LEVELCOLOR, colorline);
ObjectSet    ("FD", OBJPROP_FIBOLEVELS, 10);
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+0, 0.236);
ObjectSetFiboDescription("FD",0,"-23.6     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+1, 0.382);
ObjectSetFiboDescription("FD",1,"-38.2     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+2, 0.5);
ObjectSetFiboDescription("FD",2,"-50.0     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+3, 0.618);
ObjectSetFiboDescription("FD",3,"-61.8     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+4, 0.764);
ObjectSetFiboDescription("FD",4,"-76.4     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+5, 1.0);
ObjectSetFiboDescription("FD",5,"-100.0     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+6, 1.236);
ObjectSetFiboDescription("FD",6,"-123.6     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+7, 1.382);
ObjectSetFiboDescription("FD",7,"-138.2     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+8, 1.5);
ObjectSetFiboDescription("FD",8,"-150.0     ");
ObjectSet    ("FD", OBJPROP_FIRSTLEVEL+9, 1.618);
ObjectSetFiboDescription("FD",9,"-161.8     ");

ObjectCreate ("FR", OBJ_FIBO, 0, Time[89], 0, Time[89], 0);
ObjectSet    ("FR", OBJPROP_LEVELSTYLE, STYLE_DASH);
ObjectSet    ("FR", OBJPROP_LEVELWIDTH, 1);
ObjectSet    ("FR", OBJPROP_LEVELCOLOR, colorline);
ObjectSet    ("FR", OBJPROP_FIBOLEVELS, 5);
ObjectSet    ("FR", OBJPROP_FIRSTLEVEL+0, 0.236);
ObjectSetFiboDescription("FR",0,"23.6     ");
ObjectSet    ("FR", OBJPROP_FIRSTLEVEL+1, 0.382);
ObjectSetFiboDescription("FR",1,"38.2     ");
ObjectSet    ("FR", OBJPROP_FIRSTLEVEL+2, 0.5);
ObjectSetFiboDescription("FR",2,"50.0     ");
ObjectSet    ("FR", OBJPROP_FIRSTLEVEL+3, 0.618);
ObjectSetFiboDescription("FR",3,"61.8     ");
ObjectSet    ("FR", OBJPROP_FIRSTLEVEL+4, 0.764);
ObjectSetFiboDescription("FR",4,"76.4     ");

_N_Time = 0;
_Cur_Period = 0;
return(0);
}
//-------------------------------------------------------------------------------------------
int deinit() {
ObjectDelete("FU");
ObjectDelete("FD");
ObjectDelete("FR");
ObjectDelete("TOP");
ObjectDelete("BOTTOM");
Comment(" ");
return(0);
}
//-------------------------------------------------------------------------------------------
int start() {
if( (_N_Time != Time[0]) || (_Cur_Period != Period()) ) {
//=================================================================
double yesterday_high, yesterday_low, yesterday_close, Q, _X_Point;
double rates_mn[2][6];
ArrayCopyRates(rates_mn, Symbol(), _My_Period);
yesterday_high = rates_mn[1][3];
yesterday_low = rates_mn[1][2];
yesterday_close = rates_mn[1][4];
Q = yesterday_high - yesterday_low;

ObjectMove ("TOP", 0, Time[0], yesterday_high);
ObjectMove ("BOTTOM", 0, Time[0], yesterday_low);

ObjectMove ("FU", 0, Time[89], yesterday_high + Q);
ObjectMove ("FU", 1, Time[89], yesterday_high);

ObjectMove ("FD", 1, Time[89], yesterday_low);
ObjectMove ("FD", 0, Time[89], yesterday_low - Q);

ObjectMove ("FR", 0, Time[89], yesterday_high);
ObjectMove ("FR", 1, Time[89], yesterday_low);

_N_Time = Time[0];
_Cur_Period = Period();
//=================================================================
}
return(0);
}
//-------------------------------------------------------------------------------------------

Comments