Fast - MACD

Download script
Fast - MACD

The Watts MACD is a specialized technical analysis tool designed to visualize market momentum by interpreting price trends through several layers of moving averages. While it is based on the classic MACD (Moving Average Convergence Divergence) logic, it has been customized specifically for "Watts Scalping" systems to provide clearer visual cues for active traders.

Core Mathematical Logic

The script operates by processing price data through three primary stages:

  1. Trend Identification: It first calculates two different Exponential Moving Averages (EMAs)—one fast and one slow. By subtracting the slow average from the fast average, the tool identifies the gap between short-term price action and long-term trends.
  2. Signal Smoothing: It then takes that resulting data and applies a third moving average to create a "Signal Line." This helps filter out market noise.
  3. Histogram Generation: The final visual component is a histogram, which represents the difference between the first calculation (the MACD) and the second (the Signal Line).

Added Analytical Layers

To enhance precision beyond a standard MACD, this script incorporates two additional moving averages specifically applied to the histogram itself:

  • Short-term Smoothing: A very fast average (SMA 1) to track immediate fluctuations.
  • Medium-term Smoothing: A slightly longer average (SMA 5) to identify sustained shifts in momentum.

Visual Styles and Customization

A key feature of this script is the "Style" toggle, which allows users to choose how the histogram colors are displayed based on different trading perspectives:

  • Style 0 (Original Watts System): The histogram changes color based on its position relative to the zero line. This helps traders immediately distinguish between bullish momentum (above zero) and bearish momentum (below zero).
  • Style 1 (Momentum Shift): The histogram changes color based on whether the current bar is higher or lower than the previous one. This focuses on the rate of change, highlighting whether momentum is accelerating or decelerating, regardless of whether the price is currently positive or negative.

By combining these layers, the indicator provides a comprehensive view of where the price is going, how fast it is moving there, and whether that movement is gaining or losing strength.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
Fast - MACD
/*
 * Watts MACD: the MACD indicator as shwon in Watts scalping system.
 * However, I added a style input choice. Style 0 will plot MACD histograms
 * in two different colors based on if the histogram bar is > or < 0. The 
 * style choice of 1 will plot MACD histograms in two different colors based
 * on if current histogram bar is > or < than previous histogram bar. 
 * Style 0 is the original style of Watts system.
 * 
 * Use it at your own risk.
 *
 * Author: Peter Chen
 *
 * History: 
 *    6/13/2008: First Verision.
 */


//---- indicator settings
#property  indicator_separate_window

//Buffers needed to draw indicators
#property  indicator_buffers 5 
//Histograms
#property  indicator_color1  Gray
#property  indicator_color2  Lime
#property  indicator_color3  Red
//MA lines on histograms
#property  indicator_color4  Lime
#property  indicator_color5  DeepPink

#property  indicator_width1  1
#property  indicator_width2  1
#property  indicator_width3  1
#property  indicator_width4  2
#property  indicator_width5  2

//---- indicator parameters
extern int FastEMA = 34;
extern int SlowEMA = 89;
extern int SignalEMA = 13;
extern int HistoSMA1 = 1;
extern int HistoSMA5 = 5;
extern int Style = 1; //0 or 1
//---- indicator buffers
double     HistoBuffer[];
double     MacdBuffer[];
double     SignalBuffer[];
//These are used for painting
double     MA1Buffer[];
double     MA5Buffer[];
double     ExtBuffer0[];
double     HistoUpBuffer[];
double     HistoDnBuffer[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //3 additional buffers are used for a total of 8 buffers
   IndicatorBuffers(8);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexStyle(4,DRAW_LINE);
   
   SetIndexDrawBegin(0,SlowEMA);
   SetIndexDrawBegin(1,SlowEMA);
   SetIndexDrawBegin(2,SlowEMA);
   SetIndexDrawBegin(3,SlowEMA);
   SetIndexDrawBegin(4,SlowEMA);
   
   IndicatorDigits(Digits+2);

   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,HistoUpBuffer);
   SetIndexBuffer(2,HistoDnBuffer);
   SetIndexBuffer(3,MA1Buffer);
   SetIndexBuffer(4,MA5Buffer);
   SetIndexBuffer(5,HistoBuffer);
   SetIndexBuffer(6,MacdBuffer);
   SetIndexBuffer(7,SignalBuffer);
   
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Watts_MACD("+FastEMA+","+SlowEMA+","+SignalEMA+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Average of Oscillator                                     |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   double current = 0;
   double prev = 0;
   
   int counted_bars=IndicatorCounted();

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(int i=0; i<limit; i++)
      MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
   
   for(i=0; i<limit; i++)
      SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalEMA,0,MODE_EMA,i);

   for(i=0; i<limit; i++) 
      HistoBuffer[i]=MacdBuffer[i]-SignalBuffer[i];
      
   for(i=0; i<limit; i++) {
      MA1Buffer[i]=iMAOnArray(HistoBuffer,Bars,HistoSMA1,0,MODE_SMA,i);
   }
   
   for(i=0; i<limit; i++) {
      MA5Buffer[i]=iMAOnArray(HistoBuffer,Bars,HistoSMA5,0,MODE_SMA,i);
   }
      
      
   //Paint the bars
   for (i = 0; i < limit; i++) { 
       current = HistoBuffer[i];
       prev = HistoBuffer[i+1];
       
       if (Style == 0) {
         if (current > 0) {
           HistoUpBuffer[i] = current; 
           HistoDnBuffer[i] = 0.0;
           ExtBuffer0[i] = 0.0;
         } else if (current < 0) {
           HistoUpBuffer[i] = 0.0;
           HistoDnBuffer[i] = current;
           ExtBuffer0[i] = 0.0;   
         } else {
           HistoUpBuffer[i] = 0.0;
           HistoDnBuffer[i] = 0.0;
           ExtBuffer0[i] = current;  
         }
       
       } else  { //Assume 1
         if (current > prev) { 
           HistoUpBuffer[i] = current; 
           HistoDnBuffer[i] = 0.0;
           ExtBuffer0[i] = 0.0;
         } else if (current < prev) {
           HistoUpBuffer[i] = 0.0;
           HistoDnBuffer[i] = current;
           ExtBuffer0[i] = 0.0;
         } else {
           HistoUpBuffer[i] = 0.0;
           HistoDnBuffer[i] = 0.0;
           ExtBuffer0[i] = current;
         }
       }
   
   }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments