TrendStrengthTrio

Download script
Author: Copyright � 2006, MetaQuotes Software Corp.
TrendStrengthTrio

TrendStrengthTrio Logic Overview

The TrendStrengthTrio is a specialized technical analysis tool designed to measure the momentum and underlying strength of market trends. Rather than simply looking at price action alone, this script calculates the "distance" between different moving averages to gauge how aggressively the market is moving in a specific direction.

How the Logic Works

The core mechanism of this indicator relies on a multi-layered calculation involving Exponential Moving Averages (EMA) and Weighted Price data. Here is a breakdown of the process:

  • Comparative Analysis: The script takes a very short-term moving average as a baseline. It then calculates several longer-term moving averages at increasing intervals (based on a user-defined "Step").
  • Momentum Calculation: By subtracting these longer-term averages from the shorter-term baseline, the script identifies the gap between current price velocity and historical averages.
  • Aggregated Strength: The tool performs this calculation across ten different intervals simultaneously for each trend line. It sums these differences together to produce a cumulative "strength" value.
  • Multi-Layered Visualization: The indicator generates three distinct lines (TS1, TS2, and TS3). Each line represents a progressively larger scale of time or data:
    • TS1: The base strength calculation using the initial Step.
    • TS2: A secondary strength level calculated using a wider interval.
    • TS3: A tertiary strength level providing a broader, long-term perspective on trend momentum.

Key Features for Traders

  • Trend Differentiation: By observing the three different lines, traders can see if a trend is accelerating, slowing down, or losing steam across different time horizons.
  • Customizable Visibility: Users have the flexibility to toggle the visibility of the second and third lines, allowing for a cleaner chart layout depending on whether they prefer to focus on immediate momentum or long-term trends.
  • Weighted Sensitivity: Because the logic utilizes weighted price types, it responds dynamically to the most recent price movements while still filtering out "noise," providing a smoother representation of market sentiment.

In summary, this script acts as a diagnostic tool that translates raw price data into a visual representation of trend intensity, helping traders identify whether a current move has significant underlying power or if it is beginning to exhaust.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
TrendStrengthTrio
//+------------------------------------------------------------------+
//|                                            TrendStrengthTrio.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Orange 
#property indicator_color2 Aqua 
#property indicator_color3 Green  
//---- input parameters
extern bool      Line2Visible=true;
extern bool      Line3Visible=false;
extern int       Step=5;

double TS1[];
double TS2[];
double TS3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(3);  

   IndicatorShortName("TrendStrengthTrio"); 
    
   SetIndexBuffer(0,TS1); 
   SetIndexStyle(0, DRAW_LINE); 
   SetIndexLabel(0,"TS1");     
   SetIndexBuffer(1,TS2); 
   SetIndexStyle(1, DRAW_LINE); 
   SetIndexLabel(1,"TS2");     
   SetIndexBuffer(2,TS3); 
   SetIndexStyle(2, DRAW_LINE); 
   SetIndexLabel(3,"TS3");     
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
int    mode, shift,counted_bars=IndicatorCounted(); 
   //double ma40dbl; 
   double ma0, ma1, ma2, ma3, ma4, ma5, ma6, ma7, ma8, ma9, ma10, tmp; 
   int tmpstep;
     //---- 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; 
   tmpstep=Step;  
   for(int s = 1; s <= 4; s++)
   {
      shift=Bars-1; 
      while(shift>=0) 
      {
         mode=MODE_EMA;
         tmp=iMA(NULL,0,5,0,mode,PRICE_WEIGHTED,shift);     
         ma1=tmp-iMA(NULL,0,tmpstep,0,mode,PRICE_WEIGHTED,shift); 
         ma2=tmp-iMA(NULL,0,tmpstep*2,0,mode,PRICE_WEIGHTED,shift); 
         ma3=tmp-iMA(NULL,0,tmpstep*3,0,mode,PRICE_WEIGHTED,shift); 
         ma4=tmp-iMA(NULL,0,tmpstep*4,0,mode,PRICE_WEIGHTED,shift);  
         ma5=tmp-iMA(NULL,0,tmpstep*5,0,mode,PRICE_WEIGHTED,shift);
         ma6=tmp-iMA(NULL,0,tmpstep*6,0,mode,PRICE_WEIGHTED,shift);
         ma7=tmp-iMA(NULL,0,tmpstep*7,0,mode,PRICE_WEIGHTED,shift);
         ma8=tmp-iMA(NULL,0,tmpstep*8,0,mode,PRICE_WEIGHTED,shift);
         ma9=tmp-iMA(NULL,0,tmpstep*9,0,mode,PRICE_WEIGHTED,shift);   
         ma10=tmp-iMA(NULL,0,tmpstep*10,0,mode,PRICE_WEIGHTED,shift);         
            
         if (s==1) {TS1[shift]=ma1+ma2+ma3+ma4+ma5+ma6+ma7+ma8+ma9+ma10;}
         if ((s==2) && (Line2Visible==true)) {TS2[shift]=ma1+ma2+ma3+ma4+ma5+ma6+ma7+ma8+ma9+ma10;}
         if ((s==3) && (Line3Visible==true)) {TS3[shift]=ma1+ma2+ma3+ma4+ma5+ma6+ma7+ma8+ma9+ma10;}
           
         shift--;// 
      } 
      tmpstep+=Step;
   }      

   return(0);
  }
//+------------------------------------------------------------------+

Comments