FF Tunnel Chart

Download script
Author: Financial Freedom with Forex
FF Tunnel Chart

Overview of the FF Tunnel Logic

The FF Tunnel is a technical analysis tool designed to help traders visualize market trends, identify specific price "tunnels," and monitor overall momentum across different timeframes. It combines moving averages, Fibonacci-inspired risk levels, and weekly trend filters to provide a comprehensive snapshot of market conditions.

Key Components & Visuals

1. The Moving Average Tunnel

The script plots two primary moving averages on your chart to help identify the immediate price action:

  • 55 SMA (Median): Acts as a baseline for the "tunnel." This represents the medium-term trend.
  • 8 SMA (Close): A faster-moving average that helps track short-term price fluctuations relative to the 55 SMA.

2. Dynamic Risk Models

One of the core features is the ability to switch between three different Risk Models. Depending on your chosen setting, the script projects four specific "Fibonacci" lines above and below the 55 SMA baseline. These lines serve as potential support, resistance, or profit-taking targets:

  • Model 1: Uses tighter spreads (89 and 144 points).
  • Model 2: Uses moderate spreads (144 and 233 points).
  • Model 3: Uses wider spreads (233 and 377 points).

3. Weekly Trend Filtering

The script doesn't just look at the current chart; it also analyzes Weekly Data in the background. It calculates the relationship between a 5-period Simple Moving Average and a 21-period Exponential Moving Average on a weekly basis.

  • It determines the "Weekly Direction" (Up or Down) based on the change in this difference.
  • This helps you ensure that your short-term trades are aligned with the broader, long-term market direction.

Trading Intelligence & Alerts

Smart Filtering

The script includes a built-in safety filter. If the price is too close to the 55 SMA (within a specific narrow range), it will generate a Warning. This warns you that the market may be in a "choppy" or undecided state, suggesting you should only trade if the price breaks clearly above or below the tunnel boundaries.

Visual & Audio Feedback

The tool provides real-time feedback through an on-screen dashboard (Comment box) and alerts:

  • Dashboard: Displays the current Weekly Direction, active Risk Model, specific values for all tunnel lines, and the current filtering status.
  • Visual Alerts: The script monitors a "Slope Change" point. When the price hits this specific marker, it triggers a visual alert to notify you of a potential shift in momentum or structure.

Summary for the Trader

The FF Tunnel is designed to take the guesswork out of trend identification. By visualizing the "tunnel" of price action and comparing it against weekly momentum, it helps you stay on the right side of the market while providing clear "zones" (via the Risk Models) to manage your entries and exits.

Price Data Components
Series array that contains open time of each bar
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
FF Tunnel Chart
//+------------------------------------------------------------------+
//|                                                    FF Tunnel.mq4 |
//|                                                         FFwithFX |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Financial Freedom with Forex"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Magenta
#property indicator_color2 Red
#property indicator_color3 Silver
#property indicator_color4 Silver
#property indicator_color5 Silver
#property indicator_color6 Silver
#property indicator_color7 Blue  
#property indicator_color8 Silver
//---- input parameters
extern bool      AudioAlerts=true;
extern bool      VisualAlerts=true;
extern int       RiskModel=1;

//---- buffers
double ExtMapBuffer1[]; // 55 SMA Median
double ExtMapBuffer2[]; // 8 SMA Close
double ExtMapBuffer3[]; // 1st FibLine up
double ExtMapBuffer4[]; // 2nd FibLine up
double ExtMapBuffer5[]; // 1st FibLine down
double ExtMapBuffer6[]; // 2nd FibLine down
double ExtMapBuffer7[]; // Turning Line
double ExtMapBuffer8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"55 SMA");
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,"8 SMA");   
   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,STYLE_DOT,1,Green);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexLabel(6,"Slope Change");
   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();
   
   double curr_EMA21;
   double curr_SMA5;
   double prev_EMA21;
   double prev_SMA5;
   double WDiff;
   string Direction;
   string Filter;
  //---- 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
         ExtMapBuffer1[i]=iMA(NULL,0,55,0,MODE_SMA,PRICE_MEDIAN,i);
         ExtMapBuffer2[i]=iMA(NULL,0,8,0,MODE_SMA,PRICE_CLOSE,i);
         ExtMapBuffer7[i]=Close[i+8];
         Filter = "OK to Trade";
         

         //Model #1 89,144,233
         if(RiskModel==1)
         {
            ExtMapBuffer3[i]=ExtMapBuffer1[i]+89*Point;  
            ExtMapBuffer4[i]=ExtMapBuffer1[i]+144*Point;
            
            ExtMapBuffer5[i]=ExtMapBuffer1[i]-89*Point;
            ExtMapBuffer6[i]=ExtMapBuffer1[i]-144*Point;
         }
         
          //Model #2 144,233,377
         if(RiskModel==2)
         {
            ExtMapBuffer3[i]=ExtMapBuffer1[i]+144*Point;
            ExtMapBuffer4[i]=ExtMapBuffer1[i]+233*Point;
            
            ExtMapBuffer5[i]=ExtMapBuffer1[i]-144*Point;
            ExtMapBuffer6[i]=ExtMapBuffer1[i]-233*Point;
         }
         
          //Model #3 233,377,610
         if(RiskModel==3)
         {
            ExtMapBuffer3[i]=ExtMapBuffer1[i]+233*Point;
            ExtMapBuffer4[i]=ExtMapBuffer1[i]+377*Point;
            
            ExtMapBuffer5[i]=ExtMapBuffer1[i]-233*Point;
            ExtMapBuffer6[i]=ExtMapBuffer1[i]-377*Point;
         }         
       }
//---- Calculate the different weekly data
         curr_EMA21=iMA(NULL,PERIOD_W1,21,0,MODE_EMA,PRICE_MEDIAN,0);
         curr_SMA5=iMA(NULL,PERIOD_W1,5,0,MODE_SMA,PRICE_MEDIAN,0);
         prev_EMA21=iMA(NULL,PERIOD_W1,21,0,MODE_EMA,PRICE_MEDIAN,1);
         prev_SMA5=iMA(NULL,PERIOD_W1,5,0,MODE_SMA,PRICE_MEDIAN,1);
         WDiff=((curr_SMA5-curr_EMA21) - (prev_SMA5-prev_EMA21));
         if (WDiff > 0.0) Direction = "^^ UP ^^";
         if (WDiff < 0.0) Direction = "vv DOWN vv";          
//       } 

// Check for FILTER conditions
         if (MathAbs(ExtMapBuffer1[0]-ExtMapBuffer2[0]) < 50*Point) {
         Filter = StringConcatenate("WARNING: Only trade if Price > ",MathMin(ExtMapBuffer1[0],ExtMapBuffer2[0])+50*Point,
         " or < ",MathMax(ExtMapBuffer1[0],ExtMapBuffer2[0])-50*Point);
         }         
         
           
         Comment("4Hr Tunnel Weekly Direction : ",Direction,"\n",Filter,
         "\nRISK MODEL #",RiskModel," (0-3)\nSlope Change : ",ExtMapBuffer7[0],
         "\n","\nMA+2 : ",ExtMapBuffer4[0],"\nMA+1 : ",ExtMapBuffer3[0],
         "\nSMA55 : ",ExtMapBuffer1[0],
         "\nMA-1 : ",ExtMapBuffer5[0],"\nMA-2 : ",ExtMapBuffer6[0]);
//       }
       
       //+--------------------------------------------------------------------------+
       //-                          ALERTS    PlaySound("alert.wav");               -
       //+--------------------------------------------------------------------------+
//      if(AudioAlerts)
//      {
//         if(Close[i]>ExtMapBuffer7[0] || Close[i]<ExtMapBuffer7[0])
//         {
//            PlaySound("alert.wav");
//         }
//      }
//
      if(VisualAlerts)
      {
         if(Close[0]==ExtMapBuffer7[0] || Close[0]==ExtMapBuffer7[0])
         {
           Alert(Symbol()," ", Period(), "min Slope Change - ",Close[0],
            "\n Time: ", TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS),"\n",Filter);
         }
      }
         
  //---- done

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

Comments