Guppy MMA oscillator_001

Author: mladen
Guppy MMA oscillator_001

This custom indicator, the Guppy MMA Oscillator, is designed to provide a visual representation of market momentum by comparing short-term price trends against long-term price trends. Unlike standard indicators that might only look at one moving average, this tool aggregates multiple layers of data to give a more comprehensive view of market sentiment.

How the Logic Works

The core functionality of the script is based on a weighted calculation involving twelve different timeframes (periods). Here is a breakdown of the logic:

1. The Trend Comparison (The "Sum") The script automatically analyzes twelve specific moving average periods. It categorizes these into two distinct groups:

  • Short-Term Trends: Periods that are less than 30 units long.
  • Long-Term Trends: Periods that are 30 units or longer.

The logic works by adding the values of all short-term trends together and subtracting the values of all long-term trends from that total. By doing this, the indicator creates a "net" value. When the result is high, it suggests that short-term momentum is dominating the market; when the result is low (or negative), it suggests that long-term pressure is prevailing.

2. Smoothing and Scaling To make the data easier to read on a chart, the script applies two final refinements:

  • Scaling: The resulting sum is multiplied by 10 to ensure the movements are large enough to be clearly visible in a separate window on your platform.
  • Signal Smoothing: The script then calculates a "Signal" line (the secondary line). This uses a mathematical formula to smooth out the primary oscillations, making it easier for you to identify the direction of the trend without being distracted by minor, noisy price fluctuations.

How to Interpret the Results

The indicator appears in a separate window below your main price chart. You will see two lines (Red and Gold):

  • Momentum Strength: When the primary line moves significantly away from the zero level, it indicates a strengthening trend in that direction.
  • Trend Identification: By observing how the primary line interacts with the smoothed Signal line, you can get a clearer sense of whether the current market momentum is accelerating or beginning to lose steam.
  • Zero-Line Crossovers: The zero level acts as a baseline; moving from above the zero line to below it (or vice versa) helps highlight shifts in the balance between short-term and long-term price dynamics.
Indicators Used
Moving average indicator
12 Views
0 Downloads
0 Favorites
Guppy MMA oscillator_001
//+------------------------------------------------------------------+
//|                                          Guppy MMA oscilator.mq4 |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  Red
#property indicator_color2  Gold
#property indicator_level1  0
#property indicator_levelcolor DarkSlateGray

//
//
//
//
//

extern int Price        = PRICE_CLOSE;
extern int SignalPeriod = 13;

//
//
//
//
//

double buffer1[];
double buffer2[];
double periods[]={3,5,8,10,12,15,30,35,40,45,50,60};
int    persize;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0,buffer1);
   SetIndexBuffer(1,buffer2);
   persize =ArraySize(periods);
   return(0);
}
int deinit() { return(0); }

//
//
//
//
//

int start()
{
   double alpha = 2.0/(1.0+SignalPeriod);
   int counted_bars=IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = Bars-counted_bars;

   //
   //
   //
   //
   //

   for(i=limit; i>=0; i--)
   {
      double sum  = 0;
      for(int j=0; j<persize; j++)
      {
         if (periods[j]<30)
               sum  += iMA(NULL,0,periods[j],0,MODE_EMA,Price,i);
         else  sum  -= iMA(NULL,0,periods[j],0,MODE_EMA,Price,i);
      }
      buffer1[i] = sum*10.0;
      buffer2[i] = buffer2[i+1]+alpha*(buffer1[i]-buffer2[i+1]);
   }            
   return(0);
}

Comments