This custom technical indicator is designed to help traders visualize market momentum and identify potential trend reversals by analyzing price movements over specific timeframes. It operates by calculating the relationship between a smoothed momentum value and its absolute magnitude, providing a clearer picture of the "strength" of a move rather than just its direction.
Core Logic and Methodology
The indicator functions through a multi-step processing sequence to filter out market noise and highlight significant price actions:
1. Raw Momentum Tracking The tool begins by calculating the basic momentum of the asset. It looks at the difference between the current closing price and the previous closing price. This tells the system whether the price is moving up or down and by how much.
2. Absolute Value Analysis Parallel to the standard momentum, the script calculates the "absolute" momentum. By stripping away the direction (positive or negative) and focusing only on the size of the move, the tool can better understand the volatility and intensity of the market activity regardless of whether it is bullish or bearish.
3. Multi-Layer Smoothing (Exponential Moving Averages) To ensure that small, random price fluctuations do not create "false signals," the script applies several layers of Exponential Moving Averages (EMA) to both the standard momentum and the absolute momentum. These averages are calculated using specific periods defined by the user (First_R and Second_S), which helps in smoothing out the data into a more stable, readable trend line.
4. The "Ergodic" TSI Calculation The primary visual output (the Ergodic line) is produced by taking the double-smoothed momentum and dividing it by the double-smoothed absolute momentum. This calculation is then scaled by 100. This specific logic creates a percentage-like oscillator that shows how much of the current price movement is driven by sustained trend strength versus erratic volatility.
5. Signal Smoothing Finally, the script generates a "Signal" line. This is an additional smoothing average applied directly to the main Ergodic result. By comparing the main line against this signal line, traders can more easily identify crossover points, which are often used to determine when a momentum trend is losing steam or reversing direction.
Summary for Traders
In practical terms, this indicator doesn't just show you that the price is moving; it attempts to quantify the quality and stability of that movement. By dividing smoothed momentum by its absolute value, it helps separate "true" trend movements from mere market noise, providing a more refined view of market dynamics than a standard momentum oscillator might offer.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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 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 First_R=8;
extern int Second_S=5;
extern int SignalPeriod=5;
extern int Mode_Smooth=0;
//---- 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;
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]);
}
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);
}
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);
}
for (i=limit;i>=0;i--)
{
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_EMA,i);
}
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
Comments