Author: mladen
tcf

This tool, known as the Trend Continuation Factor (TCF), is designed to help traders visualize the underlying momentum and strength of a market trend. Instead of simply showing whether the price is going up or down, it analyzes the "velocity" of price movements over a specific period to determine how much staying power a current trend might have.

How the Logic Works

The script operates by breaking down price action into three distinct phases:

1. Measuring Price Velocity The system first looks at the immediate change in price from one moment to the next. It identifies whether the market is moving upward or downward and calculates the "Rate of Change." This tells the tool not just that a move is happening, but how aggressively it is occurring.

2. Categorizing Market Movement The logic separates these movements into two distinct buckets:

  • Positive Momentum: When the price moves up, the script records this strength as a positive value.
  • Negative Momentum: When the price moves down, the script records this strength as a negative value (expressed as a positive magnitude for calculation purposes).

3. Cumulative Tracking Rather than looking at each move in total isolation, the script creates a running tally of these strengths. It adds the current momentum to the previous momentum, effectively creating a "memory" of how much force has been building up behind the current trend.

4. The Trend Continuation Factor (The Final Result) To arrive at the final visual data seen on your chart, the tool looks back over a set number of bars (defined by the "Length" setting). It performs a comparative calculation:

  • It aggregates all the Positive Momentum over that period.
  • It subtracts the Cumulative Negative Momentum from that same period.

What This Means for the User

The resulting indicators on your screen represent the net balance between upward and downward forces.

  • When the value is high, it suggests that positive momentum significantly outweighs negative pressure, indicating a strong, healthy trend that may continue.
  • When the values shift or flatten, it suggests that the momentum is losing its "fuel," potentially signaling a period of consolidation or a weakening trend.

In short, this script acts as a momentum filter, helping you see through the "noise" of individual price candles to identify the actual strength and persistence of the prevailing market direction.

Indicators Used
Moving average indicator
8 Views
0 Downloads
0 Favorites
tcf
//+------------------------------------------------------------------+
//|                                                          tcf.mq4 |
//|                                                           mladen |
//|                                                                  |
//| Trend Continuation Factor originaly developed by M.H. Pee        |
//| TASC : 20:3 (March 2002) article                                 |
//| "Just How Long Will A Trend Go On? Trend Continuation Factor"    |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 DarkOrange

extern int Length = 35;
extern int Price  = PRICE_CLOSE;

double TcfUp[];
double TcfDo[];
double values[][4];

//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0,TcfUp);
   SetIndexBuffer(1,TcfDo);
   return(0);
}
int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+

#define plus_ch  0
#define minus_ch 1
#define plus_cf  2
#define minus_cf 3

//

int start()
{
   int counted_bars=IndicatorCounted();
   int i,r,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = Bars-counted_bars;
         if (ArrayRange(values,0) != Bars) ArrayResize(values,Bars);

   //
    for(i=limit, r=Bars-limit-1; i>=0; i--,r++)
   {
      double roc = iMA(NULL,0,1,0,MODE_SMA,Price,i)-iMA(NULL,0,1,0,MODE_SMA,Price,i+1);

         values[r][plus_ch]  = 0;
         values[r][minus_ch] = 0;
         values[r][plus_cf]  = 0;
         values[r][minus_cf] = 0;
      
         //
                      
            if (roc>0)
            {
               values[r][plus_ch] = roc;
               if (r>1)
                     values[r][plus_cf] = values[r][plus_ch]+values[r-1][plus_cf];
               else  values[r][plus_cf] = values[r][plus_ch];
            }                  
            if (roc<0)
            {
               values[r][minus_ch] = -roc;
               if (r>1)
                     values[r][minus_cf] = values[r][minus_ch]+values[r-1][minus_cf];
               else  values[r][minus_cf] = values[r][minus_ch];
            }
   
         //
                      
         TcfUp[i] = 0;
         TcfDo[i] = 0;
         for (int l=0; l<Length; l++)
         {
            TcfUp[i] += values[r-l][plus_ch]-values[r-l][minus_cf];
            TcfDo[i] += values[r-l][minus_ch]-values[r-l][plus_cf];
         }
   }      
   return(0);
}

Comments