FIBTunnel
Download scriptThis tool is designed to provide visual price guidance by creating a dynamic "tunnel" on your trading chart. Instead of relying on static horizontal lines, it generates a moving corridor that adapts to current market trends, helping traders identify potential zones of interest based on specific price offsets.
Core Logic and Functionality
1. The Trend Baseline The foundation of this indicator is an Exponential Moving Average (EMA). By using a 55-period EMA, the tool calculates a smoothed average of the recent closing prices. This serves as the central "spine" or midline of the tunnel, representing the core trend of the market at any given moment.
2. The Tunnel Expansion (Fibonacci Offsets) Rather than simply showing the moving average alone, the script projects several parallel lines above and below this baseline. These lines are calculated using specific point offsets: 21, 34, and 55.
These numbers are significant as they are derived from the Fibonacci sequence, which is frequently used in technical analysis to identify natural levels of support and resistance. By applying these values to the moving average, the tool creates a multi-layered corridor around the price action.
3. Visual Representation The script calculates eight distinct data points simultaneously:
- One central baseline.
- Three upper bounds (adding 21, 34, and 55 points to the baseline).
- Four lower bounds (subtracting 21, 34, and 55 points from the baseline).
How to Interpret the Results
As price moves across your chart, this "tunnel" follows it. When the market is in a strong trend, these lines move together in unison. For a trader, this provides a visual map of the current market volatility:
- Trend Identification: The direction of the tunnel indicates whether the overall momentum is bullish (moving up) or bearish (moving down).
- Price Boundaries: The various levels of the tunnel act as "zones." Traders can observe how price interacts with these specific Fibonacci-based offsets to gauge potential overextension or areas where the price might pull back.
- Dynamic Adaptation: Because the entire structure is based on a moving average, the tunnel constantly reshapes itself in real-time, ensuring that the support and resistance levels stay relevant to the most recent market data.
//+------------------------------------------------------------------+
//| FIBTunnel.mq4 |
//| |
//| 89, 143, 233 |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Violet
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(6,ExtMapBuffer7);
SetIndexStyle(7,DRAW_LINE);
SetIndexBuffer(7,ExtMapBuffer8);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(int i=0; i<limit; i++)
{
//---- ma_shift set to 0 because SetIndexShift called abowe
ExtMapBuffer2[i]=iMA(NULL,0,55,0,MODE_EMA,PRICE_CLOSE,i);
//21, 34 and 55 FIB for 15 min and 5 minute
ExtMapBuffer3[i]=ExtMapBuffer2[i]+21*Point;
ExtMapBuffer4[i]=ExtMapBuffer2[i]+34*Point;
ExtMapBuffer5[i]=ExtMapBuffer2[i]+55*Point;
ExtMapBuffer6[i]=ExtMapBuffer2[i]-21*Point;
ExtMapBuffer7[i]=ExtMapBuffer2[i]-34*Point;
ExtMapBuffer8[i]=ExtMapBuffer2[i]-55*Point;
}
return(0);
}
//+------------------------------------------------------------------+
Comments