T3_DPO-v1_v1

T3_DPO-v1_v1

This script is a specialized technical analysis tool designed for the MetaTrader platform. It combines two distinct mathematical concepts—the T3 Moving Average and the Detrended Price Oscillator (DPO)—to provide traders with a visual representation of price momentum and trends.

Core Logic and Functionality

The indicator operates by processing historical price data to separate the "noise" of market fluctuations from the actual underlying trend. Here is a breakdown of how it achieves this:

1. The Smoothing Foundation (T3 Methodology) At its core, the script utilizes the T3 logic, which is known for being smoother and more responsive than standard moving averages. Unlike basic averages that can lag significantly behind current price action, this tool uses a complex weighting system. It calculates multiple layers of averages to filter out erratic price movements while maintaining a close proximity to the actual market price.

2. Multi-Stage Weighting The script performs several recursive calculations. It takes the current price and passes it through a series of weighted filters. By applying specific coefficients (derived from the user-defined period), the tool "compounds" the smoothing effect. This ensures that the resulting data line reflects a stable trend rather than reacting impulsively to every minor price tick.

3. Momentum Tracking (DPO Concept) By integrating the DPO logic, the indicator focuses on the distance between current prices and their moving averages. It essentially measures "oversold" or "overbought" conditions by analyzing how much the price has deviated from its established trend.

Visual Output

The script generates two distinct visual elements in a separate window below your main trading chart:

  • The Histogram: This represents the smoothed T3 calculation. It provides a clear, vertical representation of the trend's strength and direction.
  • The Line Graph: This tracks the price data as it interacts with the smoothing algorithm, allowing you to see the relationship between raw closing prices and the calculated moving averages.

Summary for Traders

Instead of looking at raw, jagged price movements, this tool provides a refined view of market behavior. It is designed to help users identify the primary direction of the market by filtering out minor fluctuations, making it easier to spot significant trend shifts and momentum changes in real-time.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
T3_DPO-v1_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                    T3_DPO-v1.mq4 |
//|                                                                  |
//|                                        Ramdass - Conversion only |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 DarkViolet
//---- input parameters
extern int x_prd=0;
extern int t3_period=8;
extern double b=0.7;
extern int CountBars=300;
//---- buffers
double t3[];
double prise[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator line
   IndicatorBuffers(2);
   SetIndexBuffer(0,t3);
   SetIndexBuffer(1,prise);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| T3_DPO-v1                                                         |
//+------------------------------------------------------------------+
int start()
  {
   SetIndexDrawBegin(0,Bars-CountBars+t3_period+1);
   SetIndexDrawBegin(1,Bars-CountBars+t3_period+1);  
   int i,counted_bars=IndicatorCounted();
   double e1,e2,e3,e4,e5,e6,c1,c2,c3,c4,n,w1,w2, b2,b3,dpo,Prise;
//----
   if(Bars<=t3_period) return(0);
//---- initial zero
   if(counted_bars<t3_period)
   {
      for(i=1;i<=t3_period;i++) prise[Bars-i]=0.0;
      for(i=1;i<=t3_period;i++) t3[Bars-i]=0.0;
   }
//----
b2=b*b;
b3=b2*b;
c1=-b3;
c2=(3*(b2+b3));
c3=-3*(2*b2+b+b3);
c4=(1+3*b+b3+3*b2);
n=t3_period;

if (n<1) n=1;
n = 1 + 0.5*(n-1);
w1 = 2 / (n + 1);
w2 = 1 - w1;
//----
   i=Bars-CountBars-1;
   if(counted_bars>=t3_period) i=CountBars-counted_bars-1;
   while(i>=0)
     {
      dpo=iMA(NULL,0,t3_period,0,MODE_SMA,PRICE_CLOSE,i);
  
  e1 = w1*dpo + w2*e1;
  e2 = w1*e1 + w2*e2;
  e3 = w1*e2 + w2*e3;
  e4 = w1*e3 + w2*e4;
  e5 = w1*e4 + w2*e5;
  e6 = w1*e5 + w2*e6;

  t3[i] = c1*e6 + c2*e5 + c3*e4 + c4*e3;
  
   prise[i]=Close[i];
 
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments