FF Tunnel Slope

Download script
FF Tunnel Slope

This tool, titled FF Tunnel Slope, is designed to provide traders with a visual representation of price momentum and trend direction by calculating the rate of change in a specific moving average. Rather than just showing the price itself, this indicator focuses on the "velocity" or "slope" of the market's movement.

How the Logic Works

The core functionality of the script relies on three main components:

1. The Base Foundation (Simple Moving Average) The tool starts by calculating a Simple Moving Average (SMA). This is a standard technical analysis metric that smooths out price fluctuations to identify the underlying trend. You can customize the sensitivity of this average (the "SMA" parameter) to determine how quickly the indicator reacts to new price data.

2. The Slope Calculation Instead of simply plotting that moving average on your main chart, this script measures the difference between the current moving average value and the previous one.

  • If the current value is higher than the previous one, it indicates an upward slope (positive momentum).
  • If the current value is lower than the previous one, it indicates a downward slope (negative momentum).

3. Visual Representation The tool displays these results in a separate window below your main price chart. It uses two distinct visual formats:

  • A Line Graph: This tracks the continuous change in the slope, allowing you to see how steadily the trend is accelerating or decelerating.
  • A Histogram: This provides a vertical representation of that same data, making it easier to identify at a glance when the "slope" is growing larger or shrinking.

Key Objectives for the Trader

The primary goal of this script is to help traders identify momentum shifts. By observing the "Tunnel Slope," you can see not just where the price is going, but how fast it is moving in that direction. When the slope changes significantly, it often signals a potential shift in market sentiment or a transition from a strong trend into a period of consolidation.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
FF Tunnel Slope
//+------------------------------------------------------------------+
//|                                              FF Tunnel Slope.mq4 |
//|                                                         FFwithFX |
//|                                                                  |
//+------------------------------------------------------------------+
#property  copyright "Financial Freedom with Forex"
#property  link      ""
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Red
#property indicator_level1   0.0
//---- indicator parameters
//extern bool  AudioAlerts=true;
//extern bool  VisualAlerts=true;
extern int   SMA   =8;
//---- indicator buffers
double     ind_buffer1[];
double     ind_buffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexDrawBegin(0,SMA);
   SetIndexDrawBegin(1,SMA);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) && !SetIndexBuffer(1,ind_buffer2))
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("FF Tunnel Slope("+SMA+")");
   SetIndexLabel(0,"Slope");
//   SetIndexLabel(1,"SlopeH");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
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;
//---- Slope counted in the 1-st buffer
   for(int i=0; i<limit; i++)
      {
         ind_buffer1[i]=iMA(NULL,0,SMA,0,MODE_SMA,PRICE_CLOSE,i) - iMA(NULL,0,SMA,0,MODE_SMA,PRICE_CLOSE,i+1);
         ind_buffer2[i]=ind_buffer1[i];
      }
      
       //+--------------------------------------------------------------------------+
       //-                          ALERTS    PlaySound("alert.wav");               -
       //+--------------------------------------------------------------------------+
//      if(AudioAlerts)
//      {
//         if(ind_buffer1[i]==0)
//         {
//            PlaySound("alert2.wav");
//         }
//      }
//
//      if(VisualAlerts)
//      {
//         if(ind_buffer1[i]==0)
//         {
//            Alert(Symbol()," ", Period(), "min Tunnel Slope Change - ",Close[i],"\n Time: ", TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS));
//         }
//      }
//         
//      
//      
//---- done
   return(0);
  }

Comments