Multi.Period.RSI
Download scriptThis tool is designed to provide traders with a more comprehensive view of market momentum by analyzing price movements across different time horizons. Instead of looking at the Relative Strength Index (RSI)—a common momentum indicator—on just one timeframe, this script allows you to visualize how the market is behaving on a specific, higher timeframe relative to your current chart.
Core Logic and Functionality
Dynamic Timeframe Adjustment The script includes an intelligent "rounding" logic. Rather than forcing the user to input exact technical numbers, it automatically converts your desired timeframe into standard trading periods (such as 1-minute, 5-minute, 1-hour, Daily, etc.). If you input a number that doesn't perfectly match a standard period, the script intelligently rounds it to the nearest recognized timeframe.
Cross-Timeframe Analysis The primary purpose of this indicator is to synchronize data. It calculates the RSI value based on a secondary timeframe that you choose. For example, if you are looking at a very fast chart (like a 1-minute chart) but want to see the trend of a 4-hour chart, this script performs that calculation automatically.
Data Synchronization To ensure accuracy, the script maps the history correctly between timeframes. It identifies the specific point in time on your current chart that corresponds to the higher timeframe's data. This ensures that the line you see on your screen accurately represents the "big picture" momentum without being distorted by the smaller fluctuations of the immediate price action.
Key Benefits for Traders
- Trend Confirmation: By viewing a higher timeframe’s RSI on a lower timeframe chart, you can stay aware of the broader market direction while making precise entries on smaller candles.
- Simplified Navigation: The script handles the complex math of converting minutes into hours, days, or weeks, providing a clean visual output without requiring manual calculations.
- Visual Clarity: It produces a single, clear line that represents the strength of price movement, helping to identify overbought or oversold conditions on your preferred broader horizon.
//+------------------------------------------------------------------+
//| Multi.Period.RSI.mq4 |
//| Copyright © 2010, Vladimir Hlystov |
//| cmillion@narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Vladimir Hlystov"
#property link "http://cmillion.narod.ru"
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_width1 1
//---- input parameters
extern int PeriodRSI = 14;
extern int timeframe =5;
//---- buffers
double Buffer[];
//+------------------------------------------------------------------+
int init()
{
//---- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, Buffer);
//----
timeframe = next_period(timeframe);
SetIndexLabel(0, "RSI "+StrPer(timeframe));
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(int i=0; i<limit; i++)
{
Buffer[i] = iRSI(NULL,timeframe,PeriodRSI,PRICE_CLOSE,iBarShift(NULL,timeframe,Time[i],false));
}
return(0);
}
//+------------------------------------------------------------------+
int next_period(int per)
{
if (per > 43200) return(0);
if (per > 10080) return(43200);
if (per > 1440) return(10080);
if (per > 240) return(1440);
if (per > 60) return(240);
if (per > 30) return(60);
if (per > 15) return(30);
if (per > 5) return(15);
if (per > 1) return(5);
if (per == 1) return(1);
if (per == 0) return(Period());
}
//+------------------------------------------------------------------+
string StrPer(int per)
{
if (per == 1) return(" M1 ");
if (per == 5) return(" M5 ");
if (per == 15) return(" M15 ");
if (per == 30) return(" M30 ");
if (per == 60) return(" H1 ");
if (per == 240) return(" H4 ");
if (per == 1440) return(" D1 ");
if (per == 10080) return(" W1 ");
if (per == 43200) return(" MN1 ");
return("îøèáêà ïåðèîäà");
}
//+------------------------------------------------------------------+
Comments