22-FIBTunnel

Download script
Author:
22-FIBTunnel

This script is designed as a visual technical analysis tool for the MetaTrader trading platform. Its primary purpose is to identify specific price corridors or "zones" by projecting fixed mathematical offsets from a moving average baseline.

Core Logic Overview

The tool functions by calculating a dynamic "central path" on the price chart and then creating a symmetrical tunnel around that path. Here is the step-by-step breakdown of how it processes market data:

1. Establishing the Baseline The script first identifies a core trend line using an Exponential Moving Average (EMA). This moving average acts as the "spine" of the indicator, smoothing out short-term market noise to show the underlying direction of the price.

2. Creating the Symmetry Once the central moving average is established, the logic calculates several specific distance markers. It takes three distinct numerical values—89, 143, and 233—and applies them as fixed "points" above and below the moving average.

3. Defining the Tunnel Zones By adding and subtracting these points from the central baseline, the script generates a series of parallel lines on your chart:

  • Upper Bound: Three lines are drawn at set distances above the average.
  • Lower Bound: Three lines are drawn at set distances below the average.

Visual Purpose

To a trader, this creates a visible "tunnel" or corridor. Instead of looking at a single line, the indicator provides a multi-layered area of interest. The spacing between these lines is intentionally designed to help visualize potential support and resistance zones relative to the current moving trend.

By observing where the price interacts with these specific geometric boundaries, users can better identify structural shifts in the market or potential areas where price might stabilize.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
22-FIBTunnel
//+------------------------------------------------------------------+
//|                                                    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,233,0,MODE_EMA,PRICE_CLOSE,i);
         
            //21, 34 and 55 FIB for 15 min and 5 minute
            ExtMapBuffer3[i]=ExtMapBuffer2[i]+89*Point;
            ExtMapBuffer4[i]=ExtMapBuffer2[i]+143*Point;
            ExtMapBuffer5[i]=ExtMapBuffer2[i]+233*Point;
            
            ExtMapBuffer6[i]=ExtMapBuffer2[i]-89*Point;
            ExtMapBuffer7[i]=ExtMapBuffer2[i]-143*Point;
            ExtMapBuffer8[i]=ExtMapBuffer2[i]-233*Point;
       }
       

   return(0);
  }
//+------------------------------------------------------------------+

Comments