Author: Copyright � 2005, MetaQuotes Software Corp.
SMI

This tool is a custom technical analysis indicator designed to help traders identify price momentum and potential trend reversals by analyzing the relationship between current market prices and historical volatility. It operates by processing raw price data through several layers of mathematical smoothing to filter out "noise" and highlight significant movements.

Core Logic and Data Processing

The indicator functions by breaking down the market movement into three primary components:

1. Price Positioning and Volatility Tracking First, the script looks at a specific window of recent history (defined by the user-adjustable periods). It identifies the highest highs and lowest lows within that timeframe to determine the total price range (volatility) and the midpoint of that range. It then calculates how far the current closing price sits from that midpoint relative to the overall volatility.

2. Multi-Layer Smoothing (The "EMA" Chain) To ensure that the data remains readable and isn't affected by erratic, minute price fluctuations, the script applies a series of Exponential Moving Averages (EMAs). Instead of looking at just one average, the logic calculates averages of averages:

  • It smooths the price positioning data.
  • It smooths the volatility data.
  • It then applies a second round of smoothing to those results. This "nested" approach helps stabilize the indicator, ensuring that the final output represents a sustained trend rather than a temporary spike.

3. The Final Calculation and Signal Generation The final "SMI" value is produced by taking the ratio between these deeply smoothed price and volatility figures. By multiplying this ratio, the script produces a numerical value that oscillates around a zero line.

To assist in making actionable trades, the script generates a secondary "Signal" line. This is a moving average of the primary SMI value.

How to Interpret the Result

The logic provides two main visual lines on your chart:

  • The Main SMI Line: Represents the smoothed momentum of the current price.
  • The Signal Line: Acts as a "trigger" or "confirmation" line.

By observing where these two lines move in relation to each other and the zero level, traders can attempt to identify when momentum is accelerating or slowing down, providing a clearer picture of the market's direction than raw price action alone.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
2 Downloads
0 Favorites
SMI
//+------------------------------------------------------------------+
//|                                                          SMI.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_level1 0
//---- input parameters
extern int       Period_Q=14;
extern int       Period_R=10;
extern int       Period_S=14;
extern int       Signal=5;
//---- buffers
double SMI_Buffer[];
double Signal_Buffer[];
double SM_Buffer[];
double EMA_SM[];
double EMA2_SM[];
double EMA_HQ[];
double EMA2_HQ[];
double HQ_Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,SMI_Buffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Signal_Buffer);
   SetIndexLabel(0,"SMI");
   SetIndexLabel(1,"Signal SMI");
   SetIndexBuffer(2,SM_Buffer);
   SetIndexBuffer(3,EMA_SM);
   SetIndexBuffer(4,EMA2_SM);
   SetIndexBuffer(5,EMA_HQ);
   SetIndexBuffer(6,EMA2_HQ);
   SetIndexBuffer(7,HQ_Buffer);

   IndicatorShortName("SMI("+Period_Q+","+Period_R+","+Period_S+","+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;
   int i;
//   double Median_Q[];
   if(counted_bars<0) return(-1);
   //if(counted_bars>0) counted_bars--;
   limit=Bars-Period_Q-counted_bars;
  // if(counted_bars>0) counted_bars--;
//   ArrayResize(Median_Q,limit);
//   ArrayResize(HQ_Buffer,limit);
//   ArraySetAsSeries(Median_Q,true);
//   ArraySetAsSeries(HQ_Buffer,true);
   for (i=limit;i>=0;i--)
      {
      //Median_Q[i]=(High[Highest(NULL,0,MODE_HIGH,0,i)]+Low[Lowest(NULL,0,MODE_HIGH,0,i)])/2;
      HQ_Buffer[i]=High[Highest(NULL,0,MODE_HIGH,Period_Q,i)]-Low[Lowest(NULL,0,MODE_LOW,Period_Q,i)];
      SM_Buffer[i]=Close[i]-(High[Highest(NULL,0,MODE_HIGH,Period_Q,i)]+Low[Lowest(NULL,0,MODE_LOW,Period_Q,i)])/2;//Median_Q[i];
      }
//   for (i=limit;i>=0;i--)
//      {
//      SM_Buffer[i]=Close[i]-(High[Highest(NULL,0,MODE_HIGH,0,i)]+Low[Lowest(NULL,0,MODE_HIGH,0,i)])/2;//Median_Q[i];
//      }
   for (i=limit-Period_R;i>=0;i--)
      {
      EMA_SM[i]=iMAOnArray(SM_Buffer,0,Period_R,0,MODE_EMA,i);
      EMA_HQ[i]=iMAOnArray(HQ_Buffer,0,Period_R,0,MODE_EMA,i);
      }
   for (i=limit-Period_R-Period_S;i>=0;i--)
      {
      EMA2_SM[i]=iMAOnArray(EMA_SM,0,Period_S,0,MODE_EMA,i);
      EMA2_HQ[i]=iMAOnArray(EMA_HQ,0,Period_S,0,MODE_EMA,i);
      }
   for (i=limit-Period_R-Period_S-Signal;i>=0;i--)
      {
      SMI_Buffer[i]=100*EMA2_SM[i]/0.5/EMA2_HQ[i];
      }
   for (i=limit-Period_R-Period_S;i>=0;i--)
      {
      Signal_Buffer[i]=iMAOnArray(SMI_Buffer,0,Signal,0,MODE_EMA,i);
      }

//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments