Introduction
Fibonacci retracement tools are among the most powerful technical analysis instruments available to traders. The My Fibonacci MT5 indicator brings this classic tool into the modern trading era with enhanced features and seamless Expert Advisor integration specifically designed for MetaTrader 5.
This advanced indicator automatically identifies significant swing points using smart ZigZag filtering, draws adaptive Fibonacci levels based on market volatility, and provides comprehensive data output through 20 dedicated buffers for complete EA integration.
Key Features
Automatic Swing Detection: Smart ZigZag algorithm with configurable parameters
Adaptive Levels: Automatically adjusts Fibonacci levels based on market volatility
Advanced Filtering: Volume validation and smart swing filtering options
EA Integration: 20 data buffers for complete Expert Advisor access
Multi-Timeframe Support: Works across all timeframes and symbols
Customizable Appearance: Fully configurable colors and line styles
Input Parameters
Basic Settings
Fibonacci Name – Unique identifier for the object
Main Line Color – Color of the Fibonacci trendline
Default Levels Color – Color of the Fibonacci levels
Ray Extension – Extends Fibonacci levels to the right (set to true for MT5 right-side placement)
ZigZag Configuration
Depth, Deviation, BackStep – Standard ZigZag parameters
Leg Selection – Choose which swing leg to use for Fibonacci drawing
Advanced Features
Adaptive Levels – Enable/disable volatility-based level adjustment
Volume Validation – Add volume confirmation to swing points
Smart Swing Filtering – Filter out insignificant swings using ATR
Adaptive Level Colors – Color-code levels based on significance
Min Swing Size – Minimum swing size as ATR multiplier
ATR Period – Period for Average True Range calculations
Volume Period – Period for volume averaging
Fibonacci Levels
Fully customizable Fibonacci levels including standard (23.6, 38.2, 50, 61.8, 100%) and extension levels (127.2, 161.8, 261.8%)
EA Integration Technical Details
The My Fibonacci MT5 indicator provides 20 data buffers for Expert Advisor integration, offering complete access to all Fibonacci calculations and market state information.
Buffer Structure
Buffer # | Name | Description | Value Type |
---|---|---|---|
0 | Fibo_0_Buffer | 0% Fibonacci level | Price |
1 | Fibo_236_Buffer | 23.6% Fibonacci level | Price |
2 | Fibo_382_Buffer | 38.2% Fibonacci level | Price |
3 | Fibo_500_Buffer | 50% Fibonacci level | Price |
4 | Fibo_618_Buffer | 61.8% Fibonacci level | Price |
5 | Fibo_100_Buffer | 100% Fibonacci level | Price |
6 | Fibo_1618_Buffer | 161.8% Fibonacci level | Price |
7 | Fibo_Direction_Buffer | Trend direction (1=up, -1=down) | Integer |
8 | Market_Volatility_Buffer | High volatility flag (1=true, 0=false) | Boolean |
9 | Active_Levels_Buffer | Number of active Fibonacci levels | Integer |
10 | Update_Signal_Buffer | Fibonacci update signal (1=updated) | Boolean |
11 | Distance_Nearest_Buffer | Distance to nearest level in points | Double |
12 | Nearest_Level_ID_Buffer | ID of nearest Fibonacci level | Integer |
13 | Price_Position_Buffer | Price position between swings (0-1) | Double |
14 | Touch_Signal_Buffer | Level touch signal (0=none, 1=touch, 2=bounce, 3=break) | Integer |
15 | SR_Strength_Buffer | Support/Resistance strength (0-10) | Double |
16 | Volume_Confirm_Buffer | Volume confirmation (1=confirmed) | Boolean |
17 | MTF_Confluence_Buffer | Multi-timeframe confluence factor | Double |
18 | Success_Rate_Buffer | Historical success rate at current level | Double |
19 | Risk_Reward_Buffer | Risk/Reward ratio at current position | Double |
Accessing Buffer Data in EA
To access the Fibonacci data in your Expert Advisor, use the iCustom function with the appropriate buffer number:
// EA integration example
double GetFibonacciLevel(int bufferIndex)
{
return iCustom(_Symbol, _Period, “My Fibonacci MT5”,
“MyFibonacci_MT5_v11”, clrRed, clrAqua, true, // Basic settings
12, 5, 3, 1, // ZigZag settings
true, false, true, false, 0.3, 14, 20, // Advanced features
0.0, 23.6, 38.2, 50.0, 61.8, 78.6, 100.0, 127.2, 161.8, 261.8, // Levels
bufferIndex, 0); // Buffer and shift
}
// Example usage
double fibo618 = GetFibonacciLevel(4); // Get 61.8% level
double direction = GetFibonacciLevel(7); // Get trend direction
double touchSignal = GetFibonacciLevel(14); // Get touch signal
Practical EA Implementation Example
Here’s a complete example of how to use the Fibonacci data in a trading EA:
//+——————————————————————+
//| FibonacciEA.mq5 |
//| Copyright 2024, My Fibonacci MT5 |
//| aan.isnaini@gmail.com |
//+——————————————————————+
#property copyright “Copyright 2024, My Fibonacci MT5”
#property link “aan.isnaini@gmail.com”
#property version “1.00”
#property strict
// Input parameters
input double LotSize = 0.1;
input int StopLossPoints = 50;
input int TakeProfitPoints = 100;
input int MagicNumber = 12345;
// Buffer references
enum FIBO_BUFFERS {
BUFFER_0, // 0%
BUFFER_236, // 23.6%
BUFFER_382, // 38.2%
BUFFER_500, // 50%
BUFFER_618, // 61.8%
BUFFER_100, // 100%
BUFFER_1618, // 161.8%
BUFFER_DIR, // Direction
BUFFER_VOLAT, // Volatility
BUFFER_LEVELS, // Active levels
BUFFER_UPDATE, // Update signal
BUFFER_DIST, // Distance to nearest
BUFFER_NEAREST, // Nearest level ID
BUFFER_POS, // Price position
BUFFER_TOUCH, // Touch signal
BUFFER_STR, // S/R strength
BUFFER_VOL, // Volume confirmation
BUFFER_MTF, // MTF confluence
BUFFER_SUCCESS, // Success rate
BUFFER_RR // Risk/Reward
};
//+——————————————————————+
//| Expert initialization function |
//+——————————————————————+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+——————————————————————+
//| Expert deinitialization function |
//+——————————————————————+
void OnDeinit(const int reason)
{
}
//+——————————————————————+
//| Expert tick function |
//+——————————————————————+
void OnTick()
{
// Check for new bar
static datetime lastBarTime;
datetime currentBarTime = iTime(_Symbol, _Period, 0);
if(lastBarTime == currentBarTime) return;
lastBarTime = currentBarTime;
// Get Fibonacci data
double touchSignal = GetFiboData(BUFFER_TOUCH);
double direction = GetFiboData(BUFFER_DIR);
double successRate = GetFiboData(BUFFER_SUCCESS);
double rrRatio = GetFiboData(BUFFER_RR);
double nearestLevel = GetFiboData(BUFFER_NEAREST);
// Trading logic
if(touchSignal >= 1 && successRate > 60 && rrRatio > 1.5)
{
if(direction > 0 && (nearestLevel == BUFFER_382 || nearestLevel == BUFFER_618))
{
// Buy at support with good success rate and R/R
OpenTrade(ORDER_TYPE_BUY);
}
else if(direction < 0 && (nearestLevel == BUFFER_382 || nearestLevel == BUFFER_618))
{
// Sell at resistance with good success rate and R/R
OpenTrade(ORDER_TYPE_SELL);
}
}
// Check for exit conditions
CheckForExits();
}
//+——————————————————————+
//| Get Fibonacci data from indicator |
//+——————————————————————+
double GetFiboData(FIBO_BUFFERS buffer)
{
return iCustom(_Symbol, _Period, “My Fibonacci MT5”,
“MyFibonacci_MT5_v11”, clrRed, clrAqua, true,
12, 5, 3, 1,
true, false, true, false, 0.3, 14, 20,
0.0, 23.6, 38.2, 50.0, 61.8, 78.6, 100.0, 127.2, 161.8, 261.8,
buffer, 0);
}
//+——————————————————————+
//| Open a trade |
//+——————————————————————+
void OpenTrade(ENUM_ORDER_TYPE orderType)
{
double price = (orderType == ORDER_TYPE_BUY) ? Ask : Bid;
double sl = (orderType == ORDER_TYPE_BUY) ? price – StopLossPoints * _Point : price + StopLossPoints * _Point;
double tp = (orderType == ORDER_TYPE_BUY) ? price + TakeProfitPoints * _Point : price – TakeProfitPoints * _Point;
MqlTradeRequest request = {0};
MqlTradeResult result = {0};
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = LotSize;
request.type = orderType;
request.price = price;
request.sl = sl;
request.tp = tp;
request.magic = MagicNumber;
request.comment = “My Fibonacci MT5 EA”;
OrderSend(request, result);
}
//+——————————————————————+
//| Check for exit conditions |
//+——————————————————————+
void CheckForExits()
{
for(int i = PositionsTotal() – 1; i >= 0; i–)
{
ul ticket = PositionGetTicket(i);
if(PositionGetInteger(POSITION_MAGIC) == MagicNumber)
{
// Add your exit logic here
}
}
}
//+——————————————————————+
Advanced EA Strategies
The comprehensive data provided by My Fibonacci MT5 enables sophisticated trading strategies:
1. Fibonacci Bounce Strategy
// Enter on bounce from key Fibonacci levels (38.2%, 50%, 61.8%)
if(touchSignal == 2 && (nearestLevel == BUFFER_382 || nearestLevel == BUFFER_500 || nearestLevel == BUFFER_618))
{
// Additional confirmation: volume and volatility
if(GetFiboData(BUFFER_VOL) > 0 && GetFiboData(BUFFER_VOLAT) > 0)
{
OpenTrade(direction > 0 ? ORDER_TYPE_BUY : ORDER_TYPE_SELL);
}
}
2. Breakout Strategy
// Enter on breakout of Fibonacci level with volume confirmation
if(touchSignal == 3 && GetFiboData(BUFFER_VOL) > 0)
{
// Use MTF confluence for additional confirmation
if(GetFiboData(BUFFER_MTF) > 1.5)
{
OpenTrade(direction > 0 ? ORDER_TYPE_BUY : ORDER_TYPE_SELL);
}
}
3. Volatility-Based Position Sizing
// Adjust position size based on market volatility
double volatilityFactor = GetFiboData(BUFFER_VOLAT) ? 0.5 : 1.0;
double adjustedLotSize = LotSize * volatilityFactor;
Optimization Tips
Parameter Optimization: Test different ZigZag settings (Depth, Deviation, BackStep) for your specific symbol and timeframe
Level Sensitivity: Adjust the minimum swing size based on the symbol’s average true range
Timeframe Combination: Use higher timeframe Fibonacci levels for more significant support/resistance
Volume Filter: Enable volume validation in high-impact trading sessions
Conclusion
The My Fibonacci MT5 indicator provides traders with a professional-grade Fibonacci tool that seamlessly integrates with Expert Advisors. With its 20 data buffers, adaptive levels, and smart market state detection, it offers everything needed to create sophisticated Fibonacci-based trading systems.
Whether you’re building a simple bounce strategy or a complex multi-timeframe confluence system, My Fibonacci MT5 provides the accurate, reliable Fibonacci calculations that form the foundation of successful technical analysis.