TrendstrenghtEMA

Download script
Author: ][aoc 2006
TrendstrenghtEMA

This tool is designed to measure the momentum and underlying "health" of a market trend by analyzing how different timeframes interact with one another. Rather than simply looking at where the price is currently moving, this script evaluates the structural strength of the trend by calculating the variance between multiple Exponential Moving Averages (EMAs).

How the Logic Works

The core logic operates on a principle of relative distance. The script pulls seven different Moving Averages, each representing a different timeframe of market history (ranging from 5 periods up to 40 periods). By doing this, the tool can "see" both the immediate, short-term fluctuations and the broader, long-term direction of the market simultaneously.

The Calculation Process:

  1. Baseline Selection: The script identifies a primary benchmark using an 11-period Exponential Moving Average.
  2. Distance Measurement: It then calculates the mathematical distance between that primary benchmark and six other moving averages (the 5, 10, 15, 20, 25, 30, and 40-period averages).
  3. Averaging the Strength: To provide a clean, readable result, the script takes all those individual distances and calculates their average.
  4. Visual Output: This final value is displayed as a histogram.

What it Tells the Trader

Because the tool measures the "gap" between short-term and long-term averages, it acts as a gauge for trend intensity:

  • Trend Expansion: When the gaps between these various averages widen, it suggests that the current market trend is gaining significant strength and moving decisively in one direction.
  • Trend Convergence: If the distances begin to shrink or cluster together, it may indicate that the current momentum is exhausting, the trend is losing steam, or the market is entering a period of consolidation.

By distilling complex price history into a single smoothed value, this script helps traders distinguish between a healthy, sustained move and a weak, flickering price action.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
TrendstrenghtEMA
//+------------------------------------------------------------------+ 
//|                                             TrendStrengthEMA.mq4 | 
//|                                                        Xaoc 2006 | 
//|                                             http://forex.xcd.ru/ | 
//|                                          modified by Braindancer |
//+------------------------------------------------------------------+ 
#property copyright "][aoc 2006" 
#property link      "http://forex.xcd.ru/" 

#property indicator_separate_window 
#property indicator_buffers 1 

#property indicator_color1 Yellow 
#property indicator_level1 0
//#property indicator_maximum 0.02
//#property indicator_minimum -0.02

double TS[];


//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
   IndicatorBuffers(1);  

   IndicatorShortName("TrendStrengthEMA"); 
    
   SetIndexBuffer(0,TS); 
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 1, Blue); 
   SetIndexDrawBegin(0,2); 
   SetIndexLabel(0,"TS");   
              
//---- indicators 
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 
//---- TODO: add your code here 
    
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
  { 
   int    shift,counted_bars=IndicatorCounted(); 
   //double ma40dbl; 
   double ma0, ma1, ma2, ma3, ma4, ma5, ma6, ma7, ma8, ma9, tmp; 
//---- TODO: add your code here 
               

  //---- 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; 
  //---- main loop 
//---- main calculation loop 
   shift=Bars-1; 
   while(shift>=0) 
     {
   tmp=iMA(NULL,0,11,0,MODE_EMA,PRICE_CLOSE,shift);     
   ma1=tmp-iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift); 
   ma2=tmp-iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,shift); 
   ma3=tmp-iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,shift); 
   ma4=tmp-iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,shift);  
   ma5=tmp-iMA(NULL,0,25,0,MODE_EMA,PRICE_CLOSE,shift);
   ma6=tmp-iMA(NULL,0,30,0,MODE_EMA,PRICE_CLOSE,shift);
   ma7=tmp-iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,shift);
         
         
   TS[shift]=(ma1+ma2+ma3+ma4+ma5+ma6+ma7)/7;
        
     shift--;// 
     } 
         
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 

Comments