Automatic Fibonacci Indicator for MT5 (fibo_a_v1) – Full Explanation and Guide

Fibonacci retracement is one of the most widely used tools in technical analysis. Traders use it to identify potential support and resistance levels, retracement zones, continuation areas, and profit targets. However, drawing Fibonacci levels manually every time the market changes can be time-consuming and inconsistent.

Automatic Fibonacci Indicator for MT5


To solve this problem, I created fibo_a_v1, an Automatic Fibonacci Indicator for MetaTrader 5 (MT5). This indicator automatically scans a selected price range, finds the highest and lowest points, and draws a Fibonacci object directly on the chart. The goal is to make Fibonacci analysis faster, cleaner, and more objective.

What Is fibo_a_v1?

fibo_a_v1 is a custom MT5 indicator that automatically creates a Fibonacci retracement and extension object between the highest high and lowest low found within a user-defined time range.

Unlike many automatic Fibonacci tools that continuously redraw based on the latest swing, this indicator allows the trader to specify:

  • A start date and time
  • A finish date and time
  • The timeframe used for analysis
  • The direction of the Fibonacci
  • The color and visual style

This gives much more control and makes the indicator useful for backtesting, session analysis, intraday trading, and swing trading.

Main Features

1. Automatic High and Low Detection

The indicator scans all candles between the selected start and finish times and automatically finds the highest price and the lowest price. This removes the need to manually select swing points.

2. Custom Timeframe Analysis

You can choose the timeframe used for Fibonacci calculation, such as M1, M5, M15, M30, H1, H4, or D1. Even if your chart is on a different timeframe, the indicator can still calculate the Fibonacci using the selected timeframe.

3. Flexible Direction

The input FiboUpToDown controls the drawing direction:

  • true → Fibonacci is drawn from Low to High
  • false → Fibonacci is drawn from High to Low

This makes the indicator suitable for both bullish and bearish analysis.

4. Extended Fibonacci Levels

In addition to the standard retracement levels, the indicator includes important extension levels:

  • 127.2%
  • 141.4%
  • 161.8%
  • 200%
  • 261.8%

These levels are useful for projecting profit targets.

5. Ray Right

The Fibonacci is extended to the right side of the chart, allowing traders to monitor future price interaction with the levels.

Input Parameters Explained

FiboTF

input ENUM_TIMEFRAMES FiboTF = PERIOD_M5;

This determines which timeframe is used for the calculation.

Example: if the chart is H1 but FiboTF = PERIOD_M5, the indicator will scan M5 candles.

StartFibo

input string StartFibo = "2026.08.07 15:40";

The beginning of the analysis range.

FinishFibo

input string FinishFibo = "2026.08.10 06:00";

The end of the analysis range.

FiboUpToDown

input bool FiboUpToDown = false;
  • false → High to Low (bearish)
  • true → Low to High (bullish)

FiboColor

input color FiboColor = clrDeepSkyBlue;

Sets the color of all Fibonacci levels.

How the Indicator Works

Step 1 – Convert Input Time

datetime StartTime = StringToTime(StartFibo);

Step 2 – Find Bar Shift

int StartShift = iBarShift(_Symbol, FiboTF, StartTime, false);

Step 3 – Scan the Range

for (int i = StartShift; i >= FinishShift; i--)

For each candle, the indicator reads the high and low values and stores the highest and lowest prices found in the selected range.

Step 4 – Draw Fibonacci

Depending on the selected direction, the Fibonacci object is created either from low to high or from high to low.

Step 5 – Apply Levels

Level Purpose
0.0%Start point
23.6%Shallow retracement
38.2%Common pullback
50.0%Psychological level
61.8%Golden ratio
78.6%Deep retracement
100%Full move
127.2%Extension target
141.4%Extension target
161.8%Major extension target
200%Strong continuation target
261.8%Extended trend target

Practical Trading Examples

Bullish Setup

Suppose EURUSD moves from 1.1000 to 1.1100.

Set:

  • StartFibo = beginning of the move
  • FinishFibo = end of the move
  • FiboUpToDown = true

The indicator will draw Fibonacci from low to high.

Possible buy zones:

  • 38.2%
  • 50%
  • 61.8%

Targets:

  • 127.2%
  • 161.8%

Bearish Setup

Suppose XAUUSD falls from 3400 to 3350.

Set FiboUpToDown = false.

The indicator draws from high to low.

Possible sell zones:

  • 38.2%
  • 50%
  • 61.8%

Targets:

  • 127.2%
  • 161.8%

Why Use Automatic Fibonacci?

  • Speed: No need to draw manually.
  • Consistency: The same rules are applied every time.
  • Backtesting: Analyze historical ranges precisely.
  • Multi-Timeframe Precision: Use M5 for precise swings while trading on H1 or H4.
  • Objective Analysis: Removes emotional swing selection.

Best Use Cases

This indicator works especially well for:

  • Intraday trading
  • London session analysis
  • New York session analysis
  • Swing trading
  • Breakout pullbacks
  • Trend continuation setups
  • Historical market study

Limitations

No indicator is perfect. Current limitations include:

  • Manual time selection is required.
  • No automatic latest swing detection.
  • No price-touch alerts.
  • Only one Fibonacci object is managed.

Installation

  1. Open MetaTrader 5.
  2. Go to File → Open Data Folder.
  3. Open MQL5 → Indicators.
  4. Copy fibo_a_v1.mq5 into the folder.
  5. Restart MT5 or refresh the Navigator.
  6. Drag the indicator onto the chart.

Recommended Settings

Trading Style Timeframe
ScalpingM1–M5
Day TradingM5–M15
Swing TradingH1–H4
Position TradingH4–D1

Final Thoughts

fibo_a_v1 is a simple but powerful MT5 indicator designed for traders who want a faster and more disciplined way to use Fibonacci analysis. By combining automatic high/low detection, custom time ranges, multi-timeframe calculation, and extended Fibonacci targets, the indicator becomes useful for both beginners and experienced traders.

I created this tool primarily for my own trading workflow, where I often need to analyze a specific market movement and project retracement and extension levels quickly. Instead of spending time drawing Fibonacci objects manually, the indicator performs the calculation instantly and keeps the chart organized.

For best results, do not use Fibonacci levels alone. Combine them with:

  • Market structure
  • Support and resistance
  • Trend analysis
  • Candlestick confirmation
  • Volume or momentum indicators

Used correctly, Fibonacci can help identify high-probability pullback zones, continuation areas, and realistic profit targets.

Full Code (Source)


//+------------------------------------------------------------------+
//|                                              fibo_a_v1.mq5       |
//|                       Automatic Fibonacci for H1 timeframe       |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property strict
#property indicator_plots 0

//--- input
input ENUM_TIMEFRAMES FiboTF        = PERIOD_M5;

input string StartFibo     = "2026.08.07 15:40";
input string FinishFibo    = "2026.08.10 06:00";

input bool           FiboUpToDown   = false;       // true=Low to High, false=High to Low
input color          FiboColor      = clrDeepSkyBlue;
input bool           ShowPrice      = true;

//--- object name
string FiboName = "fibo_a";

//+------------------------------------------------------------------+
//| Delete object                                                    |
//+------------------------------------------------------------------+
void DeleteFibo() {
   if (ObjectFind(0, FiboName) >= 0)
      ObjectDelete(0, FiboName);
}

//+------------------------------------------------------------------+
//| Draw Fibonacci                                                   |
//+------------------------------------------------------------------+
void DrawFibo() {
   //if(_Period != FiboTF)
   //return;

   datetime StartTime = StringToTime(StartFibo);
   int StartShift = iBarShift(_Symbol, FiboTF, StartTime, false);
   if (StartShift < 0) return;

   datetime FinishTime = StringToTime(FinishFibo);
   int FinishShift = iBarShift(_Symbol, FiboTF, FinishTime, false);
   if (FinishShift < 0) return;

   //--- start candle data
   datetime startTime = iTime(_Symbol, FiboTF, StartShift);

   //--- find highest and lowest from StartShift to current bar
   double highest = -DBL_MAX;
   double lowest = DBL_MAX;
   int highShift = -1;
   int lowShift = -1;

   for (int i = StartShift; i >= FinishShift; i--) {
      double h = iHigh(_Symbol, FiboTF, i);
      double l = iLow(_Symbol, FiboTF, i);

      if (h > highest) {
         highest = h;
         highShift = i;
      }

      if (l < lowest) {
         lowest = l;
         lowShift = i;
      }
   }

   datetime highTime = iTime(_Symbol, FiboTF, highShift);
   datetime lowTime = iTime(_Symbol, FiboTF, lowShift);

   DeleteFibo();

   bool created;

   if (FiboUpToDown) {
      // Low -> High
      created = ObjectCreate(0, FiboName, OBJ_FIBO, 0,
         lowTime, lowest,
         highTime, highest);
   } else {
      // High -> Low
      created = ObjectCreate(0, FiboName, OBJ_FIBO, 0,
         highTime, highest,
         lowTime, lowest);
   }

   if (!created)
      return;

   //--- style
   ObjectSetInteger(0, FiboName, OBJPROP_COLOR, clrNONE);
   ObjectSetInteger(0, FiboName, OBJPROP_WIDTH, 1);
   ObjectSetInteger(0, FiboName, OBJPROP_RAY_RIGHT, true);
   //ObjectSetInteger(0, FiboName, OBJPROP_SELECTABLE, true);
   //ObjectSetInteger(0, FiboName, OBJPROP_SELECTED, false);

   //--- show price
   ObjectSetInteger(0, FiboName, OBJPROP_LEVELS, 12);

   double levels[12] = {
      0.0,
      0.236,
      0.382,
      0.5,
      0.618,
      0.786,
      1.0,
      1.272,
      1.414,
      1.618,
      2.0,
      2.618
   };
   string texts[12] = {
      "0.0",
      "23.6",
      "38.2",
      "50.0",
      "61.8",
      "78.6",
      "100",
      "127.2",
      "141.4",
      "161.8",
      "200",
      "261.8"
   };

   for (int i = 0; i < 12; i++) {
      ObjectSetDouble(0, FiboName, OBJPROP_LEVELVALUE, i, levels[i]);
      ObjectSetString(0, FiboName, OBJPROP_LEVELTEXT, i, texts[i] + " / %$ ");
      ObjectSetInteger(0, FiboName, OBJPROP_LEVELCOLOR, i, FiboColor);
      ObjectSetInteger(0, FiboName, OBJPROP_BACK, true);
      ObjectSetInteger(0, FiboName, OBJPROP_STYLE, STYLE_DASH);
   }
}

//+------------------------------------------------------------------+
//| OnInit                                                           |
//+------------------------------------------------------------------+
int OnInit() {
   DrawFibo();
   return (INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| OnDeinit                                                         |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
   DeleteFibo();
}

//+------------------------------------------------------------------+
//| OnCalculate                                                      |
//+------------------------------------------------------------------+
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[]) {
   DrawFibo();
   return (rates_total);
}
//+------------------------------------------------------------------+

I hope this indicator helps improve your trading analysis and saves valuable charting time. If you use fibo_a_v1 in your trading or have suggestions for future versions, feel free to share your feedback on the blog.

Happy trading and thank you for reading!