SilverMACD+_v1

Download script
SilverMACD+_v1

The Silver MACD is a specialized technical analysis tool designed to help traders visualize market momentum and trend direction more clearly than a standard Moving Average Convergence Divergence (MACD) indicator. By utilizing specific mathematical calculations, it transforms complex price data into an easy-to-read visual format.

Core Logic and Functionality

The script operates by processing three distinct layers of data to provide a comprehensive view of market activity:

1. Trend Calculation (Moving Averages) At its foundation, the tool compares two different types of moving averages. It calculates a "Fast" average (which reacts quickly to recent price changes) and a "Slow" average (which tracks the broader trend). By subtracting the slow average from the fast one, the script determines the distance between these two trends. This result represents the current momentum of the market.

2. Signal Smoothing To prevent erratic jumps caused by minor price fluctuations, the script takes that momentum result and runs it through a "Signal" calculation. This acts as a smoothing filter, creating a steady baseline that helps distinguish between temporary noise and meaningful shifts in market direction.

3. Visual Distinction (The Color Logic) What sets this specific version apart is how it presents this information on your chart. Instead of just showing two overlapping lines, the script compares the current momentum against the smoothed signal:

  • Bullish Momentum (Green): When the primary momentum value is greater than or equal to the signal value, the indicator displays a green histogram. This suggests that the upward force in the market is currently stronger than the average.
  • Bearish Momentum (Red): When the primary momentum value falls below the signal value, the indicator switches to a red histogram. This suggests that downward pressure is prevailing.

Key User Benefits

By translating these calculations into a two-color visual system, the tool allows you to see at a glance whether the market's current "pulse" is gaining strength or losing steam. It simplifies the decision-making process by highlighting the transition points between positive and negative momentum trends.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
SilverMACD+_v1
//+------------------------------------------------------------------+
//|                                                  Silver MACD.mq4 |
//|                                           Copyright © 2004, Viac |
//|                                              http://www.viac.ru/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, Viac.ru"
#property  link      "http://www.viac.ru/"

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  ForestGreen
#property  indicator_color2  Red
//---- indicator parameters
extern int FastEMA=9;
extern int SlowEMA=26;
extern int SignalSMA=9;
extern int Price=PRICE_WEIGHTED;
extern int Mode=MODE_EMA;


//---- indicator buffers
double green_buffer[];
double red_buffer[];
double MACD[];
double Signal[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(0,green_buffer);
//----
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(1,red_buffer);

   SetIndexBuffer(2,MACD);
   SetIndexBuffer(3,Signal);

//---- sets drawing line empty value
   SetIndexEmptyValue(0, 0.0);
   SetIndexEmptyValue(1, 0.0);       
   SetIndexEmptyValue(2, 0.0);
   SetIndexEmptyValue(3, 0.0);      
//----
   IndicatorDigits(Digits+1);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("SilverMACD("+FastEMA+","+SlowEMA+","+SignalSMA+")");
   SetIndexLabel(0,"GreenMACD");      
   SetIndexLabel(1,"RedMACD");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit;   
   int counted_bars=IndicatorCounted();
   int i;
//---- check for possible errors
   if(counted_bars<0) return(-1);
//
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   Print("limit=",limit);
   if (counted_bars==0) limit=Bars-SlowEMA;
//---- Âû÷èñëÿåì ìàññèâ MACD
   for(i=0; i<limit; i++)
      MACD[i]=iMA(NULL,0,FastEMA,0,Mode,Price,i)-iMA(NULL,0,SlowEMA,0,Mode,Price,i);
//---- Âû÷èñëÿåì ñèãíàëüíóþ ëèíèþ äëÿ MACD
   for(i=0; i<limit; i++)
      Signal[i]=iMAOnArray(MACD,0,SignalSMA,0,MODE_SMA,i);
//---- Åñëè MACD áîëüøå èëè ðàâíî ñèãíàëüíîé, òî çåëåíûé èíà÷å êðàñíûé 
   for (i=0; i<limit; i++) 
   {
      if (MACD[i] >= Signal[i]) 
      {
        green_buffer[i] = MACD[i];
        red_buffer[i] = 0.0;
      }
      else 
      {
        green_buffer[i] = 0.0;
        red_buffer[i] = MACD[i];
      }
   }
   return(0);
  }

Comments