DiNapoli Detrend Oscillator-HISTOGRAM
Download scriptThe DiNapoli Detrend Oscillator is a technical analysis tool designed to help traders identify whether a market's current price action is moving above or below its established trend. By isolating the "noise" of the overall trend, it allows you to focus on the immediate momentum and fluctuations of the asset.
How it Works
The logic behind this script centers on the comparison between the current closing price and a moving average.
Think of a moving average as a "smooth" line that represents the average price over a specific period. In many markets, prices can be erratic, swinging up and down rapidly. By subtracting the smoothed average from the actual closing price, the script effectively removes the long-term trend from the data. What remains is the "detrended" value—a measurement of how far the current price has strayed from its recent average.
Key Features
- Visual Representation: The tool displays its findings as a histogram in a separate window below your main price chart. This makes it easy to see the magnitude of the price deviations at a glance.
- Momentum Identification: When the values on the histogram rise, it indicates that the current price is trading higher than the recent average. Conversely, when the values drop, it suggests the price is trading below the average.
- Customizable Sensitivity: The script includes adjustable parameters that allow you to define the look-back period. This means you can tune the indicator to be more sensitive to short-term "quick" moves or more stable for identifying broader market shifts.
Practical Application
By using this oscillator, traders can better visualize the "stretch" of a price move. Instead of just seeing a price go up, the DiNapoli Detrend Oscillator shows you how much it is moving relative to its own history. It serves as a way to gauge the strength of current momentum, helping to identify whether a price move is gaining steam or beginning to flatten out against its historical average.
//+------------------------------------------------------------------+
//| DiNapoli Detrend Oscillator.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
extern int x_prd=14;
extern int CountBars=3000;
//---- buffers
double dpo[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
SetIndexBuffer(0,dpo);
//----
return(0);
}
//+------------------------------------------------------------------+
//| DPO |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars+x_prd+1);
int i,counted_bars=IndicatorCounted();
double t_prd;
//----
if(Bars<=x_prd) return(0);
//---- initial zero
if(counted_bars<x_prd)
{
for(i=1;i<=x_prd;i++) dpo[CountBars-i]=0.0;
}
//----
i=CountBars-x_prd-1;
t_prd=x_prd/2+1;
while(i>=0)
{
dpo[i]=Close[i]-iMA(NULL,0,7,MODE_SMA,0,PRICE_CLOSE,i);
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments