DiNapoli Detrend Oscillator ok
Download scriptThe DiNapoli Detrend Oscillator is a technical analysis tool designed to help traders identify momentum and price deviations from established trends. By isolating the "noise" of regular market movement, it allows you to see whether the current price is performing significantly above or below its average historical path.
Core Logic and Functionality
Price vs. Trend Baseline The primary logic of this script involves comparing the current closing price of an asset against a specific moving average. Think of the moving average as a "mean" or a steady baseline representing the general direction of the market. When the actual price sits higher than this baseline, the indicator reflects positive momentum; when it sits lower, it indicates downward pressure.
Filtering Out Volatility Instead of looking at raw, erratic price jumps, the script focuses on the distance between the price and that smoothed average. This "detrending" process removes the overarching trend to highlight shorter-term fluctuations. It helps traders determine if the market is overextending itself in one direction or if a reversal might be looming.
Visual Representation The indicator produces a single line plotted in a separate window below your main price chart. This allows you to monitor the "strength" of the price movement independently of the actual candles.
- Positive values: Indicate that the price is trading above its average trend.
- Negative values: Indicate that the price is trading below its average trend.
Key Customizations
The script relies on two main parameters to define how it behaves:
- Period (x_prd): This determines the window of time used to calculate the movement. A larger period smooths out the data further, while a smaller period makes the indicator more sensitive to rapid price changes.
- CountBars: This defines the historical depth—specifically how many past candles the script will process to generate the visual data on your screen.
In summary, this tool acts as a momentum gauge, highlighting the gap between current market activity and its long-term average to help identify potential buying or selling opportunities.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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=300;
//---- buffers
double dpo[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_LINE);
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