Author: Copyright � 2005, MetaQuotes Software Corp.
TSI-Osc_v3

This technical indicator is designed to measure and visualize market momentum by analyzing the relationship between price movements and their relative intensity. It provides a smoother, more refined look at market trends compared to standard oscillators, helping traders identify the strength of a trend and potential exhaustion points.

Core Logic Overview

The script functions by processing raw price data through several layers of mathematical smoothing and absolute value calculations. Instead of looking only at whether the price is going up or down, it focuses on how "fast" or "aggressive" those moves are.

Step-by-Step Process

The logic follows a specific sequence to arrive at the final visual lines on your chart:

  1. Momentum Calculation: The script first identifies the basic momentum by calculating the difference between the current closing price and the previous closing price.
  2. Absolute Value Tracking: It then calculates the "Absolute Momentum." By stripping away the direction (positive or negative) and focusing only on the magnitude of the move, the tool can better understand the overall volatility of the market regardless of direction.
  3. Double Smoothing (EMA): To remove "market noise" and erratic price spikes, the script applies two consecutive layers of Exponential Moving Averages (EMA). It smooths both the standard momentum and the absolute momentum. This creates a more stable trend line that reacts to significant moves while ignoring minor fluctuations.
  4. The TSI Ratio: The primary indicator (the "Ergodic" line) is created by taking the ratio of the smoothed momentum divided by the smoothed absolute momentum, then multiplying it by 100. This percentage-based approach allows the indicator to stay within a readable range while highlighting how much of the current price action is driven by strong, consistent trends versus erratic volatility.
  5. Signal Line: Finally, the script applies a third layer of smoothing specifically to the resulting TSI value. This creates a "Signal" line that follows the main trend.

How to Interpret the Results

By comparing the main Ergodic line against the Signal line, users can observe trend shifts:

  • Trend Strength: When the lines move significantly away from the zero level, it indicates a strong prevailing trend.
  • Crossovers: Much like other oscillators, when the Ergodic line crosses over or under the Signal line, it can indicate potential changes in momentum or the beginning of a new market cycle.
  • Overbought/Oversold Context: The inclusion of fixed levels (such as 50 and -50) helps users identify when the momentum might be becoming extreme in one direction.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
TSI-Osc_v3
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                      TSI-Osc.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 2
#property indicator_color1 White
#property indicator_color2 Coral
#property indicator_maximum 100
#property indicator_minimum -100
#property indicator_level1 0
#property indicator_level2 50
#property indicator_level3 -50
//---- input parameters
// M5 and M15 , 8,8,8
// M30 7,7,7
// H1 and H4 6,6,6
extern int       First_R=7;
extern int       Second_S=7;
extern int       SignalPeriod=7;
//---- buffers
double TSI_Buffer[];
double SignalBuffer[];
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(8);
   SetIndexBuffer(2, MTM_Buffer);
   SetIndexBuffer(3, EMA_MTM_Buffer);
   SetIndexBuffer(4, EMA2_MTM_Buffer);
   SetIndexBuffer(5, ABSMTM_Buffer);
   SetIndexBuffer(6, EMA_ABSMTM_Buffer);
   SetIndexBuffer(7, EMA2_ABSMTM_Buffer);

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,TSI_Buffer);
   SetIndexLabel(0,"Ergodic");
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexLabel(1,"Signal");
//----
   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;//Bars
   for (i=Bars-1;i>=0;i--)//Bars
      {
      MTM_Buffer[i]=(Close[i]-Close[i+1]);
      //MTM_Buffer[i]=((High[i]+Low[i])/2)-((High[i+1]+Low[i+1])/2);
      //MTM_Buffer[i]=(((Close[i]-Close[i+1])/Close[i+1])+Point);
      //MTM_Buffer[i]=iMomentum(NULL,0,1,PRICE_CLOSE,i)-iMomentum(NULL,0,1,PRICE_CLOSE,i+1);
      //MTM_Buffer[i]=iMomentum(NULL,0,1,PRICE_CLOSE,i)-iMomentum(NULL,0,1,PRICE_CLOSE,i+1);
      //MTM_Buffer[i]=iMomentum(NULL,0,1,PRICE_CLOSE,i)-iMomentum(NULL,0,1,PRICE_CLOSE,i+1);
      ABSMTM_Buffer[i]=MathAbs(MTM_Buffer[i]);
      }
      
   for (i=Bars-1;i>=0;i--)//Bars
      {
      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);
      }

   for (i=Bars-1;i>=0;i--)//Bars
      {
      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);
      }

   for (i=limit;i>=0;i--)//limit
      {
      TSI_Buffer[i]=100.0*EMA2_MTM_Buffer[i]/EMA2_ABSMTM_Buffer[i];
      }
   for (i=limit;i>=0;i--)//limit
      {
      SignalBuffer[i]=iMAOnArray(TSI_Buffer,0,SignalPeriod,0,MODE_EMA,i);
      }
      
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments