MTF_RSI_4TF_X4

Download script
Author: Copyright � 2004, MetaQuotes Software Corp.
MTF_RSI_4TF_X4

This script is designed for the MetaTrader trading platform to provide a comprehensive visual overview of market momentum by consolidating multiple timeframes into a single view.

Core Functionality

The primary purpose of this tool is "Multi-Timeframe" (MTF) analysis. Instead of forcing a trader to constantly switch between different charts (e.g., jumping from a 1-hour chart to a Daily chart), this script pulls the Relative Strength Index (RSI)—a standard momentum oscillator—from four different timeframes simultaneously and displays them in one dedicated window on your current screen.

How It Works

The logic follows a structured process to ensure data accuracy across different scales:

  • Multi-Timeframe Synchronization: The script identifies the exact historical moment on your current chart and "looks back" into other timeframes. It calculates where those specific moments landed on larger or smaller time periods (such as Daily, 4-Hour, or 60-minute intervals) so that the data points align perfectly with the current price action.
  • Simultaneous RSI Calculation: The tool calculates four independent RSI values at once. Each value can be customized by the user to monitor different durations (periods) and different price types (such as Close prices, Highs, or Lows).
  • Visual Layering: Each of the four RSI feeds is assigned its own distinct color and line thickness. This allows traders to see a "stack" of momentum data. For example, you might see the long-term trend in one color and the immediate short-term fluctuations in another, making it easier to spot where different market cycles are overlapping or conflicting.
  • Smart Scaling: The script includes safety checks to ensure that if a user selects a timeframe smaller than the one currently on their screen, the tool automatically adjusts to match the current chart’s period. This prevents errors and ensures the data remains readable.

User Benefits

By consolidating this information into one window, the script helps traders identify:

  1. Trend Confluence: When all four timeframes show similar momentum, it indicates a strong, unified trend.
  2. Divergence: If a short-term timeframe shows strength while a larger timeframe shows weakness, it may alert the trader to a potential trend reversal.
  3. Efficiency: It eliminates the need for manual chart switching, providing a "bird's eye view" of the market's health across multiple dimensions at a single glance.
Indicators Used
Relative strength index
14 Views
0 Downloads
0 Favorites
MTF_RSI_4TF_X4
//+------------------------------------------------------------------+
//|            MTF_RSI_4x4TF                  based:   #RSI-3TF.mq4 ik |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//|                                                                  |
//|                   29.10.2005 Ìîäåðíèçàöèÿ Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|code change by Alex.Piech.FinGeR  mod. fx-tsd.com  fxbs                               |
//|http://www.forex-tsd.com                                           |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Gold
#property indicator_color3 Blue
#property indicator_color4 DodgerBlue
#property indicator_width1 3   
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 1
#property indicator_level1 80
#property indicator_level2 70
#property indicator_level3 50
#property indicator_level4 30
#property indicator_level5 20
#property indicator_levelcolor  SlateGray
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern color RSI1_color  = Red;
extern int TF_1         = 1440;
extern int RSI1_Period = 14;
extern color RSI2_color  = Gold;
extern int TF_2         = 240;
extern int RSI2_Period = 14;
extern color MA3_color  = Blue;
extern int TF_3         = 60;
extern int RSI3_Period = 14;
extern color RSI4_color  = DodgerBlue;
extern int TF_4         = 0;
extern int RSI4_Period = 14;
extern string note = "60H1,240H4,1440D1,10080W1,43200MN1";
extern string colors = "InputsTabColors-4refrenceOnly";
//---
extern int RSI1_applied_price=0;
extern int RSI1_AjShift=0;
extern int RSI2_applied_price=0;
extern int RSI2_AjShift=0;
extern int RSI3_applied_price=0;
extern int RSI3_AjShift=0;
extern int RSI4_applied_price=0;
extern int RSI4_AjShift=0;
extern int NumberOfBars = 3000;  // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//---- input parameters
/*************************************************************************
PERIOD_M1   1
PERIOD_M5   5
PERIOD_M15  15
PERIOD_M30  30 
PERIOD_H1   60
PERIOD_H4   240
PERIOD_D1   1440
PERIOD_W1   10080
PERIOD_MN1  43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
---------------------------------------
PRICE_CLOSE    0 Close price. 
PRICE_OPEN     1 Open price. 
PRICE_HIGH     2 High price. 
PRICE_LOW      3 Low price. 
PRICE_MEDIAN   4 Median price, (high+low)/2. 
PRICE_TYPICAL  5 Typical price, (high+low+close)/3. 
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. 
You must use the numeric value of the Applied Price that you want to use
when you set the 'applied_price' value with the indicator inputs.
**************************************************************************/
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init() {
  string short_name;
   if(TF_1==0) TF_1 = Period();
   if(TF_2==0) TF_2 = Period();
   if(TF_3==0) TF_3 = Period();
   if(TF_4==0) TF_4 = Period();
 
   if (TF_1 <= Period()) TF_1 = Period();
   if (TF_2 <= Period()) TF_2 = Period();
   if (TF_3 <= Period()) TF_3 = Period();
   if (TF_4 <= Period()) TF_4 = Period();

   //---- indicator line
  SetIndexStyle (0, DRAW_LINE);
  SetIndexBuffer(0, Buffer1);
  SetIndexStyle (1, DRAW_LINE);
  SetIndexBuffer(1, Buffer2);
  SetIndexStyle (2, DRAW_LINE);
  SetIndexBuffer(2, Buffer3);
  SetIndexStyle (3, DRAW_LINE);
  SetIndexBuffer(3, Buffer4);
      //---- name for DataWindow and indicator subwindow label
  IndicatorShortName("MTF_RSI_4TFx4 |");
  //----
  SetIndexLabel(0,"RSI1["+TF_1+"]("+RSI1_Period+";"+RSI1_applied_price+")");
  SetIndexLabel(1,"RSI2["+TF_2+"]("+RSI2_Period+";"+RSI2_applied_price+")");
  SetIndexLabel(2,"RSI3["+TF_3+"]("+RSI3_Period+";"+RSI3_applied_price+")");
  SetIndexLabel(3,"RSI4["+TF_4+"]("+RSI4_Period+";"+RSI4_applied_price+")");
  //----

SetIndexShift(0,RSI1_AjShift);
SetIndexShift(1,RSI2_AjShift);
SetIndexShift(2,RSI3_AjShift);
SetIndexShift(3,RSI4_AjShift);
//----
  SetIndexDrawBegin(0,RSI1_Period);
  SetIndexDrawBegin(1,RSI2_Period);
  SetIndexDrawBegin(2,RSI3_Period);
  SetIndexDrawBegin(3,RSI4_Period);
}
//+------------------------------------------------------------------+
//| MTF_4TF                                                      |
//+------------------------------------------------------------------+
void start() {
  int LoopBegin, sh, nsb1,nsb2,nsb3,nsb4;

  if (NumberOfBars==0) LoopBegin=Bars-1;
  else LoopBegin=NumberOfBars-1;

  for (sh=LoopBegin; sh>=0; sh--) {
    nsb1=iBarShift(NULL, TF_1, Time[sh], False);
    nsb2=iBarShift(NULL, TF_2, Time[sh], False);
    nsb3=iBarShift(NULL, TF_3, Time[sh], False);
    nsb4=iBarShift(NULL, TF_4, Time[sh], False);
 
    Buffer1[sh]=iRSI(NULL, TF_1,RSI1_Period,RSI1_applied_price, nsb1);
    Buffer2[sh]=iRSI(NULL, TF_2,RSI2_Period,RSI2_applied_price, nsb2);
    Buffer3[sh]=iRSI(NULL, TF_3,RSI3_Period,RSI3_applied_price, nsb3);
    Buffer4[sh]=iRSI(NULL, TF_4,RSI4_Period,RSI4_applied_price, nsb4);
  }
}
//+------------------------------------------------------------------+

Comments