TrendStrength_1_mod

Download script
Author: ][aoc 2006

This tool is designed to measure the underlying momentum and "strength" of a market trend by analyzing how moving averages interact with one another. Instead of simply looking at the price movement itself, this script evaluates the relationship between a primary baseline and a series of secondary averages to determine the health of the current trend.

How the Logic Works

The core logic operates through a multi-step comparison process:

  1. Establishing a Baseline: The script identifies a "base" moving average (specifically a 5-period Simple Moving Average). This serves as the primary point of reference for the current price action.
  2. Comparative Analysis: The tool then calculates several other moving averages with longer timeframes (ranging from 10 to 90 periods). It subtracts each of these longer averages from the primary baseline.
  3. Calculating Divergence: By subtracting the larger, slower averages from the smaller, faster one, the script measures the "gap" or divergence between them. A larger gap typically suggests a stronger, more aggressive trend, while a shrinking gap might indicate that the trend is losing steam or consolidating.
  4. Averaging the Strength: To ensure the final result is smooth and not overly sensitive to sudden "noise" in the market, the script takes all nine of these individual differences and calculates their average.

Visual Representation

The result is displayed as a single line on a separate window below your main trading chart.

  • Positive Values: When the line sits above the zero level, it indicates that the short-term momentum is pulling away from the longer-term averages, confirming the strength of the current trend.
  • Negative Values: When the line drops below the zero level, it suggests that the price action is receding relative to its historical averages, potentially signaling a reversal or a significant cooling off in trend intensity.

By focusing on the distance between different time horizons, this indicator helps traders visualize whether a market move has "legs" or if the trend is becoming exhausted.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
TrendStrength_1_mod
//+------------------------------------------------------------------+ 
//|                                                TrendStrength.mq4 | 
//|                                                        Xaoc 2006 | 
//|                                             http://forex.xcd.ru/ | 
//+------------------------------------------------------------------+ 
#property copyright "][aoc 2006" 
#property link      "http://forex.xcd.ru/" 

#property indicator_separate_window 
#property indicator_buffers 1 

#property indicator_color1 Orange 
#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("TrendStrength"); 
    
   SetIndexBuffer(0,TS); 
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, Orange); 
   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=20; 
   while(shift>=0) 
     {
   tmp=iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,shift);     
   ma1=tmp-iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,shift); 
   ma2=tmp-iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,shift); 
   ma3=tmp-iMA(NULL,0,30,0,MODE_SMA,PRICE_CLOSE,shift); 
   ma4=tmp-iMA(NULL,0,40,0,MODE_SMA,PRICE_CLOSE,shift);  
   ma5=tmp-iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,shift);
   ma6=tmp-iMA(NULL,0,60,0,MODE_SMA,PRICE_CLOSE,shift);
   ma7=tmp-iMA(NULL,0,70,0,MODE_SMA,PRICE_CLOSE,shift);
   ma8=tmp-iMA(NULL,0,80,0,MODE_SMA,PRICE_CLOSE,shift);
   ma9=tmp-iMA(NULL,0,90,0,MODE_SMA,PRICE_CLOSE,shift);         
         
   TS[shift]=(ma1+ma2+ma3+ma4+ma5+ma6+ma7+ma8+ma9)/9;
        
     shift--;// 
     } 
         
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 


Comments