MACDTrad2

This tool is designed to analyze price momentum and identify potential trends within a financial chart. It works by comparing two different types of moving averages to determine how the speed and strength of price changes are evolving over time.

Core Logic Breakdown

1. Momentum Tracking (The MACD Line) The script first looks at two different moving averages: a "Fast" one (which reacts quickly to recent price changes) and a "Slow" one (which tracks the broader, longer-term trend). By subtracting the Slow average from the Fast average, the tool calculates the distance between them. This gap tells us how much momentum the market currently has. If the gap is widening, the trend is gaining strength; if it is narrowing, the trend may be losing steam.

2. The Signal Line To smooth out these fluctuations and make the data easier to read, the script takes the results from the first step and calculates a secondary moving average of that data. This acts as a "Signal Line." Traders often look for the relationship between the primary momentum line and this signal line to identify turning points—specifically when the momentum crosses above or below this smoother path.

3. The Visual Histogram Finally, the script generates a visual histogram. While the first two calculations are used to determine the underlying trend, the histogram provides a customized visual representation of the current price relative to the momentum. It calculates a specific difference between the closing price and the gap between our two main lines (multiplied by a factor of 10). This helps highlight the intensity of price movements more clearly on the chart.

Summary of Use

Essentially, this script filters out the "noise" of minor price fluctuations to reveal the underlying heartbeat of the market. It provides three layers of information: the current momentum, a smoothed signal for identifying potential shifts, and a histogram to visualize the overall strength of the price action relative to those trends.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
MACDTrad2
//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 3
#property  indicator_color3  Blue
#property  indicator_width3  2
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double     MacdBuffer[];
double     SignalBuffer[];
double     HistoBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(Digits+1);
//---- indicator buffers mapping
   SetIndexBuffer(0,MacdBuffer);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexBuffer(2,HistoBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")    !! :)");
   SetIndexLabel(0,"MACD YO");
   SetIndexLabel(1,"Signal YO");
   SetIndexLabel(2,"H I S T O :):)");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   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);
//---- signal line counted in the 2-nd buffer
   for(i=0; i<limit; i++)
      SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
//---- histogram line counted in the 3-nd buffer
   for(i=0; i<limit; i++)
      HistoBuffer[i]=Close[i]-(MacdBuffer[i]-SignalBuffer[i])*10;
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments