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

This script is a specialized technical analysis tool designed to help traders identify momentum and trend strength in financial markets. It functions as an oscillator, meaning it moves up and down relative to a zero line to show the intensity of price movement.

Core Logic Overview

The primary objective of this script is to measure how much "thrust" there is behind a current price trend while filtering out unnecessary market noise. It achieves this through a multi-step calculation process:

1. Momentum Tracking The logic begins by calculating the difference between two moving averages at different points in time. Instead of just looking at raw price changes, it looks at how the average price has shifted over a specific period. This helps determine if the market is accelerating or decelerating.

2. Absolute Intensity Calculation The script then takes the "absolute value" of that momentum. In simpler terms, it measures the magnitude of the move regardless of whether the price is going up or down. This allows the tool to focus on the strength of the volatility rather than just the direction.

3. Multi-Layer Smoothing To prevent the indicator from jumping around erratically (which can lead to false signals), the script applies several layers of "smoothing." It processes the data through multiple sequences of Exponential Moving Averages (EMA). This creates a refined curve that highlights the underlying trend while ignoring minor, insignificant price fluctuations.

4. The TSI Calculation The final primary value (the main line on your chart) is generated by taking the smoothed momentum and dividing it by the smoothed absolute intensity. By multiplying this result by 100, the script produces a percentage-like scale. This tells you what proportion of the current market volatility is actually moving in the direction of the trend.

5. The Signal Line Finally, the script generates a secondary "Signal" line. This is a smoothed version of the main TSI value. Traders typically look at the relationship between these two lines:

  • When the main line crosses above the signal line, it can suggest strengthening bullish momentum.
  • When the main line crosses below the signal line, it can suggest weakening bearish momentum.

Summary for the User

Think of this tool as a "speedometer" for market trends. It filters out the "static" of daily price movements to show you the true velocity of the market. By looking at the distance between the main line and the signal line, you can gauge whether a trend is gaining strength, losing steam, or becoming exhausted.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
19 Views
0 Downloads
0 Favorites
TSI-OscM
//+------------------------------------------------------------------+
//|                                                          TSI.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//mod2009fxtsd
#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 Red
//#property indicator_maximum 100
//#property indicator_minimum -100
//#property indicator_level1 0

//---- input parameters
extern int       MAPeriod=3;
extern int       MAmode  =1;
extern int       MAPrice =5;
extern int       MomPeriod=1;

extern int       First_R=8;
extern int       Second_S=5;
extern int       SignalPeriod=5;
extern int       Mode_Smooth=1;

extern string     note_Price = "0C 1O 2H 3L 4Md 5Tp 6WghC, Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string   MA_Method_ = "SMA0 EMA1 SMMA2 LWMA3";


//---- 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,"TSI");
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexLabel(1,"Signal");
   IndicatorShortName("TSI "+MAPeriod+"("+First_R+","+Second_S+","+SignalPeriod+")");

//----
   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;
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-counted_bars-1;
    for (i=limit;i>=0;i--)
      {
      //MTM_Buffer[i]=Close[i]-Close[i+1];
      //MTM_Buffer[i]=iMomentum(NULL,0,MomPeriod,MomPrice,i);
        MTM_Buffer[i]=iMA(NULL,0,MAPeriod,0,MAmode,MAPrice,i)-iMA(NULL,0,MAPeriod,0,MAmode,MAPrice,i+MomPeriod);
        ABSMTM_Buffer[i]=MathAbs(MTM_Buffer[i]);
      }
      
    for (i=limit;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);
      }

    for (i=limit;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);
      }

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

Comments