dinapli osilattor

Download script
dinapli osilattor

This tool is designed to help traders identify price momentum by removing the "noise" of long-term trends from current market movements. It functions as a visual oscillator, meaning it appears in a separate window below your main trading chart, allowing you to see price fluctuations independently of the actual price scale.

How the Logic Works

The core purpose of this script is to measure the distance between the current market price and its moving average. Here is a breakdown of the logic:

1. Identifying the Trend Baseline The script calculates a Simple Moving Average (SMA) based on a specific timeframe you define. Think of this moving average as the "baseline" or the "fair value" of the asset over a set period. It smooths out minor price zig-zags to show the broader direction of the market.

2. Measuring the Deviation Instead of looking at where the price is alone, the script subtracts that moving average baseline from the current closing price. By doing this, it isolates the "detrended" movement.

  • When the resulting value is positive, it indicates that the price is trading above its recent average (showing bullish strength).
  • When the resulting value is negative, it indicates that the price is trading below its recent average (showing bearish weakness).

3. Visualizing Momentum The result is plotted as a smooth blue line. Rather than showing you how much a currency or stock costs, it shows you how far the price has "stretched" away from its average. This helps traders spot overextended movements, potential reversals, or shifts in momentum that might be harder to see on a standard price chart.

Key Settings

  • DPO Period: Determines the window of time used to calculate the initial data points.
  • MA Period: Controls how "sensitive" the moving average baseline is. A shorter period makes the indicator react faster to new price changes, while a longer period makes it smoother and slower to react.
  • CountBars: Limits how much historical data is displayed on the screen at once to keep the visual interface clean.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
dinapli osilattor
//+------------------------------------------------------------------+
//| DiNapoli Detrend Oscillator.mq4 
//| Treberk, www.forex-tsd.com - 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[];
extern int MAPeriod=7;


//+------------------------------------------------------------------+
//| 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();
  
//----
   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;
   

   while(i>=0)
     {
     dpo[i]=Close[i]-iMA(NULL,0,MAPeriod,MODE_SMA,0,PRICE_CLOSE,i);


      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments