FIBOstfTunnel

Download script
Author:
FIBOstfTunnel

This script functions as a visual trading tool designed to map out specific price zones on your trading chart. By analyzing current market trends, it automatically generates a series of parallel lines that act as a "tunnel" for price action.

Core Logic and Mechanism

The tool operates based on a three-step logic process:

1. Trend Identification The foundation of the script is a Moving Average (specifically an Exponential Moving Average). This acts as the "spine" of the tunnel. It smooths out short-term market noise to identify the primary direction in which the price is currently moving.

2. Dynamic Calculation Rather than drawing static lines that stay in one place, the script dynamically calculates a series of offsets based on that moving average. It uses specific mathematical constants—modeled after Fibonacci principles (21, 34, and 55)—to determine exactly how far above and below the main trend line the "walls" of the tunnel should be placed.

3. Visual Mapping The script then projects these calculations onto your chart simultaneously. It renders eight distinct lines:

  • Upper Boundary: Three lines extending above the moving average.
  • Lower Boundary: Three lines extending below the moving average.

Practical Purpose for Traders

By creating this "tunnel" effect, the tool provides a visual representation of potential support and resistance zones. Instead of looking at a single line, traders can see a corridor of price activity. This helps in identifying:

  • Price Volatility: How wide the "tunnel" expands or contracts based on market movement.
  • Trend Strength: Whether the price is staying within the predicted boundaries or breaking out of them.
  • Entry and Exit Zones: Providing a clearer visual framework for deciding when to enter a trade based on where the price sits relative to the Fibonacci-based offsets.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
FIBOstfTunnel
//+------------------------------------------------------------------+
//|                                                    FIBTunnel.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Violet
#property indicator_color3 PowderBlue
#property indicator_color4 PowderBlue
#property indicator_color5 MistyRose
#property indicator_color6 PowderBlue
#property indicator_color7 PowderBlue
#property indicator_color8 MistyRose
//---- 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,STYLE_DOT);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
   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