Author: Copyright � 2005, MetaQuotes Software Corp.
TSI

This technical indicator is designed to provide traders with a visual representation of market momentum, specifically focusing on the strength and direction of price movements. By filtering out "noise" from the raw price data, it helps identify whether the current trend is gaining steam or losing energy.

Core Logic Overview

The script operates through a multi-stage calculation process that transforms raw price data into a smoothed percentage value. Here is the step-by-step logic:

1. Measuring Raw Momentum The process begins by calculating the "Momentum." It looks at the difference between the current closing price and the previous closing price. This tells the system how much the price moved in a single step. Simultaneously, it calculates the "Absolute Momentum," which treats all movements as positive values, regardless of whether the price went up or down.

2. Smoothing the Data (First Pass) Raw momentum can be very erratic. To fix this, the script applies an Exponential Moving Average (EMA) to both the standard momentum and the absolute momentum. This "softens" the data, making it less jumpy and easier to read while still reacting quickly to new information.

3. Advanced Smoothing (Second Pass) To further refine the signal and remove minor fluctuations, the script applies a second layer of Exponential Moving Averages to the already smoothed results. By layering these averages, the indicator ensures that only significant, sustained trends are highlighted, preventing traders from reacting to insignificant price flickers.

4. Final Calculation and Scaling In the final step, the script performs a ratio calculation. It divides the smoothed momentum by the smoothed absolute momentum and multiplies the result by 100.

How to Interpret the Result

The final output is a percentage-based line shown in a separate window on your chart:

  • Direction: Because it uses a ratio of momentum to absolute movement, the resulting line shows you the direction of the trend.
  • Strength: The percentage scale helps you understand the intensity of the move.
  • Stability: Thanks to the double-layer smoothing (the two different "R" and "S" periods), the yellow line provides a much cleaner path than standard momentum indicators, helping you stay on the right side of the trend without being distracted by minor market volatility.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
TSI
  //+------------------------------------------------------------------+
//|                                                          TSI.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int       First_R=5;
extern int       Second_S=8;
//---- buffers
double TSI_Buffer[];
double MTM_Buffer[];
double EMA_MTM_Buffer[];
double EMA2_MTM_Buffer[];
double ABSMTM_Buffer[];
double EMA_ABSMTM_Buffer[];
double EMA2_ABSMTM_Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(7);
   SetIndexBuffer(1, MTM_Buffer);
   SetIndexBuffer(2, EMA_MTM_Buffer);
   SetIndexBuffer(3, EMA2_MTM_Buffer);
   SetIndexBuffer(4, ABSMTM_Buffer);
   SetIndexBuffer(5, EMA_ABSMTM_Buffer);
   SetIndexBuffer(6, EMA2_ABSMTM_Buffer);

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,TSI_Buffer);
   SetIndexLabel(0,"TSI");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit,i;
   limit=Bars-counted_bars-1;
   for (i=Bars-1;i>=0;i--)
      {
      MTM_Buffer[i]=Close[i]-Close[i+1];//iMomentum(NULL,0,1,PRICE_CLOSE,i);
      ABSMTM_Buffer[i]=MathAbs(MTM_Buffer[i]);
      //TSI_Buffer[i]=ABSMTM_Buffer[i];
      }
      
   for (i=Bars-1;i>=0;i--)
      {
      EMA_MTM_Buffer[i]=iMAOnArray(MTM_Buffer,0,First_R,0,MODE_EMA,i);
      EMA_ABSMTM_Buffer[i]=iMAOnArray(ABSMTM_Buffer,0,First_R,0,MODE_EMA,i);
      //TSI_Buffer[i]=EMA_ABSMTM_Buffer[i];
      }

   for (i=Bars-1;i>=0;i--)
      {
      EMA2_MTM_Buffer[i]=iMAOnArray(EMA_MTM_Buffer,0,Second_S,0,MODE_EMA,i);
      EMA2_ABSMTM_Buffer[i]=iMAOnArray(EMA_ABSMTM_Buffer,0,Second_S,0,MODE_EMA,i);
      //TSI_Buffer[i]=EMA2_ABSMTM_Buffer[i];
      }

   for (i=Bars-1;i>=0;i--)
      {
      TSI_Buffer[i]=100.0*EMA2_MTM_Buffer[i]/EMA2_ABSMTM_Buffer[i];
      }
      
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments