Trend_CF

The Trend_CF indicator is designed to help traders identify the underlying momentum and strength of a market trend by analyzing price movements over a specific timeframe. Instead of simply looking at whether the price is going up or down, this tool calculates a "Continuation Factor" to provide a clearer picture of how strongly that movement is sustained.

How the Logic Works

The indicator operates by breaking down the price action into two primary components: individual price changes and their cumulative progression. Here is the step-by-step logic used to generate the visual data:

1. Tracking Price Movement Direction The script looks at each consecutive price candle. It determines if the current price is higher or lower than the previous one.

  • If the price rises, the tool measures the positive gain.
  • If the price falls, it measures the negative drop.

2. Calculating Momentum Accumulation Rather than treating every price change as an isolated event, the indicator builds a "running total" of these movements. It essentially tracks how much momentum has built up over time in both upward and downward directions separately. This allows the tool to understand the "weight" of the current trend relative to what happened previously.

3. Determining the Continuation Factor (CF) The core intelligence of the script lies in its final calculation. It takes the sum of these movements over a user-defined period (the T3_Period) and performs a crossover comparison:

  • It subtracts the accumulated downward momentum from the upward movement.
  • It subtracts the accumulated upward momentum from the downward movement.

4. Visual Representation The result is plotted as two distinct lines in a separate window below your main chart:

  • Trend_CF1 (Green): Represents the net strength of the upward trend adjusted against the preceding downward pressure.
  • Trend CF2 (Orange): Represents the net strength of the downward trend adjusted against the preceding upward pressure.

Summary for the Trader

By observing these two lines, you can see which direction currently holds the most "weight." When one line moves significantly away from the other, it suggests a strong continuation of the current trend. Conversely, when the lines begin to converge or flatten, it indicates that the momentum is losing steam, potentially signaling a transition or a period of consolidation in the market.

Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
Trend_CF
//+------------------------------------------------------------------+
//|                                                     Trend_CF.mq4 |
//|                                         CF = Continuation Factor |
//|               Converted by and Copyright: Ronald Verwer/ROVERCOM |
//|                                                         27/04/06 |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Orange
#property indicator_width1 2
#property indicator_width2 2

extern int T3_Period = 16;
extern double T3_Continuation_Factor = 0.618;

double t1[];
double t2[];
double x_p[];
double x_n[];
double y_p[];
double y_n[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
   {
//---- indicators setting
   
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
   IndicatorShortName("T3 TrendCF "+T3_Period);
   
   IndicatorBuffers(6);
   SetIndexBuffer(0,t1);
   SetIndexBuffer(1,t2);
   SetIndexBuffer(2,x_p);
   SetIndexBuffer(3,x_n);
   SetIndexBuffer(4,y_p);
   SetIndexBuffer(5,y_n);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexLabel(0,"Trend_CF1 ("+T3_Period+")");
   SetIndexLabel(1,"Trend CF2 ("+T3_Period+")");
   
   //----
   return(0);
   }

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
   {
   int i,q,limit;
   double chp,chn,cffp,cffn;

   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;

//---- indicator calculation
   for(i=limit; i>=0; i--)
      {
      if (Close[i]>Close[i+1])
         {
         x_p[i]=Close[i]-Close[i+1];
         y_p[i]=x_p[i]+y_p[i+1];
         x_n[i]=0;
         y_n[i]=0;
         }
      else
         {
         x_n[i]=Close[i+1]-Close[i];
         y_n[i]=x_n[i]+y_n[i+1];
         x_p[i]=0;
         y_p[i]=0;
         }

      chp=0;chn=0;cffp=0;cffn=0;
      for(q=i+T3_Period;q>=i;q--)
         {
         chp=x_p[q]+chp;
         chn=x_n[q]+chn;
         cffp=y_p[q]+cffp;
         cffn=y_n[q]+cffn;
         }
         
      t1[i]=chp-cffn;
      t2[i]=chn-cffp;
     
      }
//----
   return(0);
   }
//+------------------------------------------------------------------+

Comments