EMA_Trend_Indicator

Download script
Author: Copyright � 2005, Metaquotes
EMA_Trend_Indicator

This tool is designed to help traders identify and visualize market trends by monitoring price movements through a dual-layered smoothing technique. Instead of looking at raw, jagged price data which can be noisy and confusing, this script calculates specific "moving averages" to highlight the underlying direction of the market.

How the Logic Works

The script operates by tracking four distinct data points simultaneously, categorized into two different speeds:

1. The Fast Tracking Layer (Short-Term Momentum) The tool first calculates a "Fast" average based on a shorter timeframe (defaulted to 21 periods). It looks specifically at both the high and low price points of each candle. This layer is designed to react more quickly to recent price changes, capturing immediate momentum.

2. The Slow Tracking Layer (Long-Term Trend) The tool then calculates a "Slow" average based on a longer timeframe (defaulted to 34 periods). By looking at a wider window of data, this layer filters out minor fluctuations and "market noise," providing a clearer picture of the overall established trend.

Visual Interpretation

By plotting these averages on your chart, the indicator provides a visual framework for analysis:

  • Price Smoothing: By using Exponential Moving Averages (EMAs), the script gives more weight to recent price action, ensuring that the lines stay relevant to current market conditions while still maintaining a smooth curve.
  • Trend Identification: The interaction between the Fast and Slow layers allows traders to see whether the immediate momentum is aligning with or diverging from the broader trend.
  • High/Low Range Monitoring: Because the script calculates averages for both the "Highs" and the "Lows" of price candles, it creates a visible corridor of activity, helping users see the boundaries within which the market is currently trading.

In essence, this script simplifies complex price action into four organized lines, allowing you to distinguish between temporary price spikes and sustained market movements at a glance.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
EMA_Trend_Indicator
//+------------------------------------------------------------------+
//|                                          EMA_Trend_Indicator.mq4 |
//|                                Copyright © 2006, Robert L Hill   |
//+------------------------------------------------------------------+
// Uses an idea from david to use EMAs to determine trend
#property copyright "Copyright © 2005, Metaquotes"
#property link      "mailto:metaquotes@metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 Purple
#property indicator_color3 Purple
#property indicator_color4 Yellow
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2

//---- input parameters
extern int FastMAPeriod=21;
extern int SlowMAPeriod=34;

//---- buffers
double fastEMA_HighBuffer[];
double fastEMA_LowBuffer[];
double slowEMA_HighBuffer[];
double slowEMA_LowBuffer[];
//---- variables

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   //---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,slowEMA_HighBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,slowEMA_LowBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,fastEMA_HighBuffer);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,fastEMA_LowBuffer);
   SetIndexDrawBegin(0,SlowMAPeriod);
   //---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MA Trend ");
   //----
   return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   //---- 
   
   //----
   return(0);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int limit;
   int counted_bars = IndicatorCounted();
   //---- check for possible errors
   if (counted_bars<0) return(-1);
   //---- last counted bar will be recounted
   if (counted_bars>0) counted_bars--;
   limit = Bars - counted_bars;

   for(int i=limit; i>=0; i--)
   {
     fastEMA_HighBuffer[i] = iMA(NULL,0,FastMAPeriod,0,MODE_EMA,PRICE_HIGH,i);
     fastEMA_LowBuffer[i] = iMA(NULL,0,FastMAPeriod,0,MODE_EMA,PRICE_LOW,i);
     slowEMA_HighBuffer[i] = iMA(NULL,0,SlowMAPeriod,0,MODE_EMA,PRICE_HIGH,i);
     slowEMA_LowBuffer[i] = iMA(NULL,0,SlowMAPeriod,0,MODE_EMA,PRICE_LOW,i);
   }
   
   //----
   return(0);
}
//+------------------------------------------------------------------+

Comments