This tool is designed to provide traders with a visual representation of market momentum by identifying the distance between two different types of price averages. It functions as a "Detrend Price Oscillator," which helps filter out long-term noise to focus on shorter-term price movements.
How the Logic Works
The script operates by comparing two moving averages of different lengths:
- The Fast Moving Average: This tracks short-term price trends. Because it is "fast," it reacts quickly to recent price changes.
- The Slow Moving Average: This tracks long-term price trends. It moves more deliberately and represents the broader direction of the market over a longer period.
By calculating the difference between these two averages, the script identifies whether the current price is pulling away from its long-term average or returning toward it.
Visual Interpretation
The result is plotted as a single line in a separate window below your main price chart:
- Positive Movement: When the line rises above the zero mark, it indicates that the short-term price momentum is higher than the long-term average, suggesting an upward trend or "bullish" strength.
- Negative Movement: When the line drops below the zero mark, it suggests that the short-term price is lower than the long-term average, indicating a downward trend or "bearish" weakness.
- The Zero Line: The zero level acts as the equilibrium point. When the oscillator crosses this line, it signals a shift in the relationship between the fast and slow trends, which many traders use to identify potential changes in market direction.
Summary of Purpose
Instead of looking at raw price numbers, this script simplifies the data into a clean oscillation. It allows you to see how much "stretch" exists between current momentum and historical averages, helping you gauge whether a trend is accelerating or losing steam.
//+------------------------------------------------------------------+
//| DPO.mq4 |
//| Detrend Price Oscillator |
//| Copyright © 2006, firedave |
//| http://www.fx-review.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, firedave"
#property link "http://www.fx-review.com/"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_level1 0
#property indicator_width1 2
extern int
FastMAperiod = 30,
FastMAtype = 1,
FastMAprice = 0,
SlowMAperiod = 100,
SlowMAtype = 1,
SlowMAprice = 0;
double
TS[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// IndicatorBuffers(2);
IndicatorDigits(0);
IndicatorShortName("DPO ("+FastMAperiod+","+SlowMAperiod+")");
SetIndexBuffer(0,TS);
SetIndexStyle(0, DRAW_LINE);
SetIndexLabel(0,"DPO");
SetIndexDrawBegin(0,2);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,
limit,
counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for (i=limit-1; i>=0; i--)
{
TS[i] = NormalizeDouble((iMA(NULL,0,FastMAperiod,0,FastMAtype,FastMAprice,i) - iMA(NULL,0,SlowMAperiod,0,SlowMAtype,SlowMAprice,i))/Point,0);
}
return(0);
}
//+------------------------------------------------------------------+
Comments