How to Build an Advanced Automatic Fibonacci Indicator in MQL5 for MetaTrader 5
Sunday, August 9, 2026MetaTrader 5 is one of the most powerful trading platforms for technical analysis and algorithmic trading. Many traders use Fibonacci levels to identify support, resistance, retracement zones, and potential reversal areas. However, drawing Fibonacci manually every day can be time-consuming and may lead to inconsistency between trading sessions.
To solve this problem, I created an MQL5 indicator called **Auto Fibo Close High/Low**. This indicator automatically draws Fibonacci levels based on the current day’s H1 range, displays yesterday’s range, calculates the average daily range (ADR), shows useful trading statistics on the chart, and generates alerts when price approaches important levels.
The indicator starts with the following declaration:
#property indicator_chart_window#property indicator_plots 0
Because it works with chart objects such as Fibonacci tools and trend lines, it does not use standard indicator buffers or plots.
==================================================
MAIN IDEA OF THE INDICATOR
==================================================
The core concept is very simple but extremely useful for intraday trading:
1. Detect the first H1 candle of the current trading day.
2. Find the highest and lowest prices from that candle until the current time.
3. Draw a Fibonacci object from the low to the high.
4. Add the daily open as a custom Fibonacci level.
5. Optionally draw yesterday’s range.
6. Alert the trader when price gets close to the highest or lowest level.
7. Display ADR, spread, bar countdown, floating PnL, and time information directly on the chart.
This creates a complete trading framework without requiring manual chart preparation.
==================================================
INPUT SETTINGS
==================================================
The indicator includes several customizable inputs:
input int signalGAP = 10;input bool ShowAlert = true;input bool ShowToday = true;input bool ShowYesterday = true;input color ColorOpen = clrPurple;input color ColorHighest = clrMaroon;input color ColorLowest = clrDarkGreen;input bool LatestH4Open = false;
These settings allow the trader to adapt the indicator to different strategies.
- signalGAP defines how many points away price can be before an alert is triggered.
- ShowAlert enables or disables alerts.
- ShowToday draws today’s Fibonacci range.
- ShowYesterday draws yesterday’s Fibonacci range.
- ColorOpen changes the open level color.
- ColorHighest changes the highest level color.
- ColorLowest changes the lowest level color.
- LatestH4Open draws a horizontal line at the latest H4 opening price.
==================================================
REMOVING OLD OBJECTS
==================================================
A good MQL5 indicator should clean up its objects when removed from the chart.
if (StringFind(name, fiboName) >= 0)ObjectDelete(0, name);
This ensures that all Fibonacci objects created by the indicator are deleted automatically. It prevents the chart from becoming cluttered with old objects.
==================================================
DATA SYNCHRONIZATION
==================================================
Inside OnCalculate, the indicator first checks whether H1 data is ready.
if (!SeriesInfoInteger(_Symbol, PERIOD_H1, SERIES_SYNCHRONIZED))return rates_total;if (Bars(_Symbol, PERIOD_H1) < 10)return rates_total;
These checks are very important, especially when MetaTrader has just started or historical data is still downloading. Without them, the indicator could produce invalid values or runtime errors.
==================================================
CREATING TODAY’S FIBONACCI RANGE
==================================================
When ShowToday is enabled, the function CreateTodayH1Line is executed.
CreateTodayH1Line(fiboName);
The indicator calculates the start of the current trading day:
datetime today = StringToTime(TimeToString(TimeCurrent(), TIME_DATE));
Then it finds the first H1 candle of the day:
int firstShift = iBarShift(_Symbol, PERIOD_H1, today, false);
After that, it scans all H1 candles from the beginning of the day until the current candle to determine the highest and lowest prices.
for (int i = firstShift; i >= 0; i--){double h = iHigh(_Symbol, PERIOD_H1, i);double l = iLow(_Symbol, PERIOD_H1, i);if (h > highest) highest = h;if (l < lowest) lowest = l;}
This produces a dynamic intraday range that updates automatically as the market moves.
==================================================
DRAWING THE FIBONACCI OBJECT
==================================================
The Fibonacci object is created using the lowest and highest prices.
ObjectCreate(0, name, OBJ_FIBO, 0, time1, lowest, time2, highest);
The object is then styled:
ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, true);ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 0, ColorHighest);ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 1, ColorLowest);ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 2, ColorOpen);
The Fibonacci extends to the right, allowing the levels to remain visible as new candles appear.
==================================================
ADDING THE DAILY OPEN LEVEL
==================================================
One feature that makes this indicator different from a standard Fibonacci tool is the custom open level.
double openLevel = ((highest - open) / rangeHighestLowest);
This value is added as an additional Fibonacci level:
ObjectSetDouble(0, name, OBJPROP_LEVELVALUE, 2, openLevel);
The final structure becomes:
- 0% = Highest price
- 100% = Lowest price
- Custom level = Daily open
Many intraday traders use the daily open as a directional reference. Combining it with the day’s range creates a very practical trading framework.
==================================================
YESTERDAY’S RANGE
==================================================
The indicator can also draw yesterday’s range using daily data.
double highest = iHigh(_Symbol, PERIOD_D1, dayShift);double lowest = iLow(_Symbol, PERIOD_D1, dayShift);double open = iOpen(_Symbol, PERIOD_D1, dayShift);
Because the daily candle already contains the complete range, there is no need to scan H1 candles. This provides a clean reference for previous-day support and resistance.
==================================================
PRICE ALERTS
==================================================
The indicator can alert when price approaches the highest or lowest level.
double highestGAP = MathAbs(currentPrice - highest) / _Point;if (highestGAP <= signalGAP)Alert(_Symbol + " highest " + DoubleToString(highestGAP, 0));
A similar block is used for the lowest level.
This is useful for traders waiting for price to retest the extremes of the daily range.
==================================================
M5 CONFIRMATION TREND LINES
==================================================
When an alert is triggered, the indicator examines the last five M5 candles.
For bullish conditions:
if (iOpen(_Symbol, PERIOD_M5, m) < iClose(_Symbol, PERIOD_M5, m))
For bearish conditions:
if (iOpen(_Symbol, PERIOD_M5, m) > iClose(_Symbol, PERIOD_M5, m))
The highest bullish open or lowest bearish open is used to draw an additional horizontal trend line.
ObjectCreate(0, UpTrendLine, OBJ_TREND, 0, time1, lastm5highest, time2, lastm5highest);
This creates a secondary intraday reference level that can help with entries, stop-loss placement, and trade management.
==================================================
AVERAGE DAILY RANGE (ADR)
==================================================
The indicator calculates the average daily range of the last completed days.
for (int i = 1; i <= days; i++){double high = iHigh(_Symbol, PERIOD_D1, i);double low = iLow(_Symbol, PERIOD_D1, i);total += (high - low);}
The current day’s range is compared with the ADR.
double todayRangePercent = (todayRange / averageRange) * 100.0;
This tells the trader whether the market has already moved more or less than its recent average. For example, if today’s range has reached 120% of ADR, the market may be overextended.
==================================================
CHART INFORMATION PANEL
==================================================
One of the most practical features is the information panel displayed on the chart.
theComment = theComment + "Price = " + DoubleToString(SymbolInfoDouble(_Symbol, SYMBOL_ASK), Digits());theComment = theComment + "\nSpread = " + IntegerToString(SymbolInfoInteger(_Symbol, SYMBOL_SPREAD));
The panel also shows:
- Time remaining until the current bar closes
- Total floating PnL in points
- GMT time
- Server time
- Local time
- ADR
- Today’s range and its percentage of ADR
This transforms the indicator into a compact trading dashboard.
==================================================
FLOATING PNL CALCULATION
==================================================
The function GetTotalPnLPips loops through all open positions for the current symbol.
double pnl_points = (current_price - open_price) / tick_size;
It automatically handles both buy and sell positions and returns the total floating result in points.
This is especially useful for active traders managing multiple positions on the same symbol.
==================================================
OPTIONAL H4 OPEN LINE
==================================================
If enabled, the indicator draws a horizontal line at the latest H4 opening price.
double open1 = iOpen(_Symbol, PERIOD_H4, barShift);
Many intraday traders use the H4 open as a directional bias level. Price trading above the H4 open may suggest bullish intraday conditions, while trading below it may suggest bearish conditions.
==================================================
WHY THIS INDICATOR IS USEFUL
==================================================
This indicator combines several tools that traders usually apply manually:
- Daily range analysis
- Fibonacci levels
- Daily open reference
- Previous-day levels
- ADR measurement
- Price proximity alerts
- M5 confirmation levels
- H4 bias line
- Real-time trading statistics
By automating these tasks, the trader can focus more on decision-making and less on chart preparation.
==================================================
PERFORMANCE NOTES
==================================================
Because the indicator creates and deletes chart objects frequently, it is best used on charts with sufficient historical data. Avoid attaching multiple copies of the same indicator to the same chart unless you use different object names.
The synchronization checks and range validation included in the code help prevent common startup errors.
==================================================
FULL SOURCE CODE
==================================================
//+------------------------------------------------------------------+
//| Auto Fibo Close High/Low.mq5 |
//| Fibo from Highest Close (0%) to Lowest Close (100%) |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_plots 0 // No plots, only objects
//+------------------------------------------------------------------+
//| Custom Settings |
//+------------------------------------------------------------------+
input int signalGAP = 10; // GAP Point for Alert
input bool ShowAlert = true; // Turn on Alert
input bool ShowToday = true; // Today Line
input bool ShowYesterday = true; // Yesterday Line
input color ColorOpen = clrPurple;
input color ColorHighest = clrMaroon;
input color ColorLowest = clrDarkGreen;
input bool LatestH4Open = false;
string fiboName = "holo";
int OnInit() {
return (INIT_SUCCEEDED);
}
void OnDeinit(const int reason) {
int total = ObjectsTotal(0, 0, -1);
for (int i = total - 1; i >= 0; i--) {
string name = ObjectName(0, i, 0, -1);
// delete only Fibonacci objects with "holo" in the name
if (StringFind(name, fiboName) >= 0) {
ObjectDelete(0, name);
}
}
Comment("");
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime & time[],
const double & open[],
const double & high[],
const double & low[],
const double & close[],
const long & tick_volume[],
const long & volume[],
const int & spread[]) {
//--- Wait until synchronize
if (!SeriesInfoInteger(_Symbol, PERIOD_H1, SERIES_SYNCHRONIZED))
return rates_total;
//--- Wait until data enough
if (Bars(_Symbol, PERIOD_H1) < 10)
return rates_total;
if (ShowToday) {
CreateTodayH1Line(fiboName);
}
if (ShowYesterday) {
CreateYesterdayH1Line(fiboName);
}
double todayRange = iHigh(_Symbol, PERIOD_D1, 0) - iLow(_Symbol, PERIOD_D1, 0);
if (MathAbs(todayRange) <= _Point) {
Print("Range not ready yet, skip fibo calculation");
return rates_total;
}
double averageRange = GetAverageDailyRange(9);
double averageRangePoint = GetAverageDailyRangePoints(9);
double todayRangePercent = (todayRange / averageRange) * 100.00;
string theComment = "\n";
theComment = theComment + "Price = " + DoubleToString(SymbolInfoDouble(_Symbol, SYMBOL_ASK), Digits());
theComment = theComment + "\nSpread = " + IntegerToString(SymbolInfoInteger(_Symbol, SYMBOL_SPREAD));
theComment = theComment + "\nBar End = " + TimeToString((iTime(_Symbol, _Period, 0) + PeriodSeconds(_Period)) - TimeCurrent(), TIME_SECONDS);
theComment = theComment + "\nPnL = " + DoubleToString(GetTotalPnLPips(), 0) + " point";
theComment = theComment + "\n";
theComment = theComment + "\nGMT Date Time = " + TimeToString(TimeGMT(), TIME_DATE | TIME_SECONDS);
theComment = theComment + "\nServer Date Time = " + TimeToString(TimeCurrent(), TIME_DATE | TIME_SECONDS);
theComment = theComment + "\nLocal Date Time = " + TimeToString(TimeLocal(), TIME_DATE | TIME_SECONDS);
theComment = theComment + "\n";
theComment = theComment + "\nADR (9 days) = " + DoubleToString(averageRange, 0) + " pips / " + DoubleToString(averageRangePoint, 0) + " point";
theComment = theComment + "\nToday Range = " + DoubleToString(todayRange, 0) + " pips / " + DoubleToString(todayRange / _Point, 0) + " point / " + DoubleToString(todayRangePercent, 2) + "%";
Comment(theComment);
if(LatestH4Open) {
CreateH4OpenHorizontal(fiboName, 1);
}
return (rates_total);
}
//+------------------------------------------------------------------+
//| Create Fibonacci H1 Today |
//+------------------------------------------------------------------+
void CreateTodayH1Line(string name = "HOLO") {
//--- fibo name
int dayShift = 0;
name = name + "H1" + IntegerToString(dayShift);
//--- start of today
datetime today = StringToTime(TimeToString(TimeCurrent(), TIME_DATE));
//--- shift of first H1 candle today (00:00)
int firstShift = iBarShift(_Symbol, PERIOD_H1, today, false);
if (iTime(_Symbol, PERIOD_H1, firstShift) < today) {
firstShift--;
}
if (firstShift < 0) {
Print("Cannot find today's H1 candle");
return;
}
//--- open of first H1 candle today
double open = iOpen(_Symbol, PERIOD_H1, firstShift);
//--- find highest and lowest H1 of today
double highest = -DBL_MAX;
double lowest = DBL_MAX;
// scan from first H1 candle today down to current H1 candle
for (int i = firstShift; i >= 0; i--) {
datetime t = iTime(_Symbol, PERIOD_H1, i);
if (t < today)
break;
double h = iHigh(_Symbol, PERIOD_H1, i);
double l = iLow(_Symbol, PERIOD_H1, i);
if (h > highest) highest = h;
if (l < lowest) lowest = l;
}
//--- remove old fibo if exists
ObjectDelete(0, name);
//--- create Fibonacci object
datetime time1 = iTime(_Symbol, PERIOD_H1, firstShift); // 00:00 H1
datetime time2 = TimeCurrent();
if (!ObjectCreate(0, name, OBJ_FIBO, 0, time1, lowest, time2, highest)) {
Print("Failed to create Fibonacci");
return;
}
//--- style
ObjectSetInteger(0, name, OBJPROP_COLOR, clrNONE);
ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, true);
ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 0, ColorHighest);
ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 1, ColorLowest);
ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 2, ColorOpen);
ObjectSetInteger(0, name, OBJPROP_BACK, true);
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_SOLID);
//--- levels: Open, High, Low
ObjectSetInteger(0, name, OBJPROP_LEVELS, 3);
// Level 0 = Highest
ObjectSetDouble(0, name, OBJPROP_LEVELVALUE, 0, 0.0);
ObjectSetString(0, name, OBJPROP_LEVELTEXT, 0, IntegerToString(dayShift) + " H1 highest" + " = %$ ");
// Level 1 = Lowest
ObjectSetDouble(0, name, OBJPROP_LEVELVALUE, 1, 1.0);
ObjectSetString(0, name, OBJPROP_LEVELTEXT, 1, IntegerToString(dayShift) + " H1 lowest" + " = %$ ");
// Level 2 = Open
double rangeHighestLowest = highest - lowest;
if (MathAbs(rangeHighestLowest) <= _Point) {
Print("Range not ready yet, skip fibo calculation");
return;
}
double openLevel = ((highest - open) / rangeHighestLowest) * 1.0;
ObjectSetDouble(0, name, OBJPROP_LEVELVALUE, 2, openLevel);
ObjectSetString(0, name, OBJPROP_LEVELTEXT, 2, IntegerToString(dayShift) + " H1 open" + " = %$ ");
Print(_Symbol,
" Today Open=", open,
" Highest=", highest,
" Lowest=", lowest);
if (ShowAlert) {
double currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);
/*double openGAP = MathAbs(currentPrice - open) / _Point;
if(openGAP <= signalGAP) {
Alert(_Symbol + " open " + DoubleToString(openGAP, 0));
} */
double highestGAP = MathAbs(currentPrice - highest) / _Point;
if (highestGAP <= signalGAP) {
Alert(_Symbol + " highest " + DoubleToString(highestGAP, 0));
//--- Add Second Line
double lastm5highest = -DBL_MAX;
for (int m = 1; m <= 5; m++) {
if (iOpen(_Symbol, PERIOD_M5, m) < iClose(_Symbol, PERIOD_M5, m)) {
double m5o = iOpen(_Symbol, PERIOD_M5, m);
if (m5o > lastm5highest) lastm5highest = m5o;
}
}
string UpTrendLine = name + "UpTrendLine";
if (ObjectCreate(0, UpTrendLine, OBJ_TREND, 0, time1, lastm5highest, time2, lastm5highest)) {
ObjectSetInteger(0, UpTrendLine, OBJPROP_COLOR, clrOrange);
ObjectSetInteger(0, UpTrendLine, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, UpTrendLine, OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSetInteger(0, UpTrendLine, OBJPROP_RAY_LEFT, false);
ObjectSetInteger(0, UpTrendLine, OBJPROP_RAY_RIGHT, true);
}
}
double lowestGAP = MathAbs(currentPrice - lowest) / _Point;
if (lowestGAP <= signalGAP) {
Alert(_Symbol + " lowest " + DoubleToString(lowestGAP, 0));
//--- Add Second Line
double lastm5lowest = DBL_MAX;
for (int m = 1; m <= 5; m++) {
if (iOpen(_Symbol, PERIOD_M5, m) > iClose(_Symbol, PERIOD_M5, m)) {
double m5o = iOpen(_Symbol, PERIOD_M5, m);
if (m5o < lastm5lowest) lastm5lowest = m5o;
}
}
string DownTrendLine = name + "DownTrendLine";
if (ObjectCreate(0, DownTrendLine, OBJ_TREND, 0, time1, lastm5lowest, time2, lastm5lowest)) {
ObjectSetInteger(0, DownTrendLine, OBJPROP_COLOR, clrOrange);
ObjectSetInteger(0, DownTrendLine, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, DownTrendLine, OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSetInteger(0, DownTrendLine, OBJPROP_RAY_LEFT, false);
ObjectSetInteger(0, DownTrendLine, OBJPROP_RAY_RIGHT, true);
}
}
}
}
//+------------------------------------------------------------------+
//| Create Fibonacci H1 Yesterday |
//+------------------------------------------------------------------+
void CreateYesterdayH1Line(string name = "HOLO") {
//--- fibo name
int dayShift = 1;
name = name + "H1" + IntegerToString(dayShift);
//--- Get OHLC
double highest = iHigh(_Symbol, PERIOD_D1, dayShift);
double lowest = iLow(_Symbol, PERIOD_D1, dayShift);
double open = iOpen(_Symbol, PERIOD_D1, dayShift);
double close = iClose(_Symbol, PERIOD_D1, dayShift);
//--- remove old fibo if exists
ObjectDelete(0, name);
//--- create Fibonacci object
datetime timeStart = iTime(_Symbol, PERIOD_D1, dayShift);
datetime timeEnd = iTime(_Symbol, PERIOD_D1, dayShift - 1);
if (!ObjectCreate(0, name, OBJ_FIBO, 0, timeStart, lowest, timeEnd, highest)) {
Print("Failed to create Fibonacci");
return;
}
//--- style
ObjectSetInteger(0, name, OBJPROP_COLOR, clrNONE);
ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, true);
ObjectSetInteger(0, name, OBJPROP_RAY_LEFT, false);
ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 0, ColorHighest);
ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 1, ColorLowest);
ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, 2, ColorOpen);
ObjectSetInteger(0, name, OBJPROP_BACK, true);
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_SOLID);
//--- levels: Open, High, Low
ObjectSetInteger(0, name, OBJPROP_LEVELS, 3);
// Level 0 = Highest
ObjectSetDouble(0, name, OBJPROP_LEVELVALUE, 0, 0.0);
ObjectSetString(0, name, OBJPROP_LEVELTEXT, 0, IntegerToString(dayShift) + " H1 highest" + " = %$ ");
// Level 1 = Lowest
ObjectSetDouble(0, name, OBJPROP_LEVELVALUE, 1, 1.0);
ObjectSetString(0, name, OBJPROP_LEVELTEXT, 1, IntegerToString(dayShift) + " H1 lowest" + " = %$ ");
// Level 2 = Open
double rangeHighestLowest = highest - lowest;
if (MathAbs(rangeHighestLowest) <= _Point) {
Print("Range not ready yet, skip fibo calculation");
return;
}
double openLevel = ((highest - open) / rangeHighestLowest) * 1.0;
ObjectSetDouble(0, name, OBJPROP_LEVELVALUE, 2, openLevel);
ObjectSetString(0, name, OBJPROP_LEVELTEXT, 2, IntegerToString(dayShift) + " H1 open" + " = %$ ");
}
//+------------------------------------------------------------------+
//| Calculate total Profit/Loss of all open positions in pips |
//+------------------------------------------------------------------+
double GetTotalPnLPips() {
double total_pips = 0;
for (int i = PositionsTotal() - 1; i >= 0; i--) {
ulong ticket = PositionGetTicket(i);
if (PositionGetString(POSITION_SYMBOL) == _Symbol) {
double open_price = PositionGetDouble(POSITION_PRICE_OPEN);
double current_price = (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) ?
SymbolInfoDouble(_Symbol, SYMBOL_BID) :
SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
double tick_size = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
// Calculate PnL in points
double pnl_points = (current_price - open_price) / tick_size;
// Convert points to pips
double pnl_pips = pnl_points * (tick_size / point);
// Add to total (for Buy, profit is positive; for Sell, profit is reversed)
if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
total_pips -= pnl_pips;
else
total_pips += pnl_pips;
}
}
return total_pips;
}
//+------------------------------------------------------------------+
//| Average Daily Range (ADR) for last N completed days |
//+------------------------------------------------------------------+
double GetAverageDailyRange(int days = 10) {
double total = 0.0;
int count = 0;
// Start from yesterday (shift 1), skip current unfinished day
for (int i = 1; i <= days; i++) {
double high = iHigh(_Symbol, PERIOD_D1, i);
double low = iLow(_Symbol, PERIOD_D1, i);
if (high > 0 && low > 0) {
total += (high - low);
count++;
}
}
if (count == 0)
return 0.0;
return total / count;
}
//+------------------------------------------------------------------+
//| Average Daily Range in points |
//+------------------------------------------------------------------+
double GetAverageDailyRangePoints(int days = 10) {
return GetAverageDailyRange(days) / _Point;
}
//+------------------------------------------------------------------+
//| Create horizontal trend line at H4 |
//+------------------------------------------------------------------+
void CreateH4OpenHorizontal(string name = "H4Open", int barShift = 1) {
name = name + "H4Open";
datetime time1 = iTime(_Symbol, PERIOD_H4, barShift);
datetime time2 = TimeCurrent();
double open1 = iOpen(_Symbol, PERIOD_H4, barShift);
if(ObjectFind(0, name) >= 0)
ObjectDelete(0, name);
ObjectCreate(0, name, OBJ_TREND, 0, time1, open1, time2, open1);
ObjectSetInteger(0, name, OBJPROP_COLOR, clrOrange);
ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_DASHDOT);
ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, true);
}
==================================================
CONCLUSION
==================================================
The Auto Fibo Close High/Low indicator is a powerful example of advanced object-based programming in MQL5. It goes far beyond a standard Fibonacci tool by automatically adapting to the current market structure, adding meaningful custom levels, generating alerts, calculating ADR, and displaying real-time trading information.
For forex, gold, and index traders using the H1 timeframe, this indicator can significantly speed up chart analysis and provide a consistent framework for identifying high-probability trading zones.
The complete source code includes important functions such as:
- CreateTodayH1Line
- CreateYesterdayH1Line
- GetAverageDailyRange
- GetTotalPnLPips
- CreateH4OpenHorizontal
Studying this project is an excellent way to learn MQL5 techniques including object handling, multi-timeframe analysis, dynamic Fibonacci levels, alert generation, and chart-based dashboards.
