This technical indicator is designed to analyze market momentum by measuring the "Continuation Factor" of price movements. Rather than simply looking at where the price is currently sitting, the logic focuses on the velocity and consistency of the trend over a specific timeframe.
Core Logic and Mechanics
The script operates by breaking down price action into two distinct components: upward movement (positive) and downward movement (negative). It treats these movements independently to determine which direction holds the most weight in the current market cycle.
1. Movement Tracking For every new price candle, the tool calculates the specific difference between the current close and the previous close.
- If the price rises, it records that growth as a positive value.
- If the price falls, it records that decline as a negative value.
2. Cumulative Momentum (The "Continuation Factor") The indicator doesn't just look at these individual changes in isolation; it creates a running total of these movements. By adding each new change to the previous sum, the script builds a cumulative history of momentum. This allows the tool to understand not just that the price moved, but how much "energy" is building behind a specific trend.
3. Period Analysis The user can define a specific window (the T3 Period) to evaluate this momentum. The script looks back over this set number of bars to aggregate all the positive and negative cumulative totals. This helps filter out "noise"—minor, insignificant price flickers—and focuses on the broader, more significant trends.
4. Final Output Generation The final values displayed on your chart are derived by comparing these opposing forces:
- Trend Line 1 (Green): Calculated by taking the sum of positive momentum and subtracting the total negative momentum. A higher value indicates strong bullish persistence.
- Trend Line 2 (Orange): Calculated by taking the sum of negative momentum and subtracting the total positive momentum. A higher value indicates strong bearish persistence.
Summary for the Trader
In simple terms, this script acts as a "momentum balance" scale. Instead of just telling you that the price is going up or down, it calculates how much "strength" is behind the current move compared to the opposing force. By visualizing these two distinct lines, traders can better identify when a trend is gaining significant power or when the momentum is beginning to exhaust itself.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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