#RSI-3TF
Download scriptThis tool is designed to provide traders with a multi-layered perspective on market momentum by combining three different timeframes into a single visual display. Instead of looking at just one set of data, this indicator allows you to observe how the "Relative Strength Index" (RSI)—a common measure of whether an asset is overbought or oversold—behaves across three distinct scales simultaneously.
How the Logic Works
The core functionality of this script relies on Multi-Timeframe Analysis. It takes data from three different periods (for example, a short-term, medium-term, and long-term view) and aligns them onto your current chart. Here is the step-by-step breakdown of its logic:
- Time Synchronization: The script identifies the exact moment in time for every candle on your current screen. It then "looks back" into the history of three other specific timeframes to find the corresponding price data for that exact moment.
- Independent Calculation: It calculates a unique RSI value for each of these three timeframes independently. By using different periods for each (such as 30 minutes, 1 hour, and 4 hours), it creates a comprehensive picture of market behavior.
- Data Overlay: The script takes those three separate calculations and maps them onto one single window. This allows you to see, at a glance, if the short-term momentum is moving in the same direction as the long-term trend, or if there is a contradiction between them.
Visual Presentation
To make this data easy to interpret, the tool organizes the information as follows:
- Three Distinct Lines: Each timeframe is represented by its own line, allowing you to track the "heartbeat" of the market across different scales.
- Reference Zones: The display includes standard horizontal levels (typically 70, 50, and 30). These serve as visual cues to help you identify when the market might be reaching an extreme point (overbought or oversold) relative to those different timeframes.
- Customizable History: You can choose how many past bars of data the script should calculate, ensuring the tool remains efficient while providing enough historical context for your analysis.
By consolidating this information, the indicator helps remove the need to switch constantly between different charts, providing a unified view of market strength and potential reversals across multiple time horizons.
//+------------------------------------------------------------------+
//| #RSI-3TF.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//| |
//| 29.10.2005 Ìîäåðíèçàöèÿ Êèì Èãîðü Â. aka KimIV |
//| http://www.kimiv.ru |
//|code change by Alex.Piech.FinGeR |
//|http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
//----
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 Yellow
#property indicator_color3 Red
#property indicator_level1 70
#property indicator_level2 30
#property indicator_level3 50
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int TF_1 =0;
extern int RSI_Period_1=14;
extern int TF_2 =30;
extern int RSI_Period_2=14;
extern int TF_3 =60;
extern int RSI_Period_3=14;
extern int NumberOfBars=1000; // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double RSIBuffer1[];
double RSIBuffer2[];
double RSIBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init()
{
string short_name;
//---- indicator line
SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(0, RSIBuffer1);
SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 3);
SetIndexBuffer(1, RSIBuffer2);
SetIndexStyle (2, DRAW_LINE, STYLE_SOLID, 3);
SetIndexBuffer(2, RSIBuffer3);
//---- name for DataWindow and indicator subwindow label
short_name="RSI("+RSI_Period_1+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
short_name="RSI("+RSI_Period_2+")";
SetIndexLabel(1,short_name);
short_name="RSI("+RSI_Period_3+")";
SetIndexLabel(2,short_name);
SetIndexDrawBegin(0,RSI_Period_1);
SetIndexDrawBegin(1,RSI_Period_2);
SetIndexDrawBegin(2,RSI_Period_3);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
void start()
{
int LoopBegin, sh, nsb,nsb2,nsb3;
if (NumberOfBars==0) LoopBegin=Bars-1;
else LoopBegin=NumberOfBars-1;
//----
for(sh=LoopBegin; sh>=0; sh--)
{
nsb3=iBarShift(NULL, TF_1, Time[sh], False);
nsb=iBarShift(NULL, TF_2, Time[sh], False);
nsb2=iBarShift(NULL, TF_3, Time[sh], False);
RSIBuffer1[sh]=iRSI(NULL, TF_1, RSI_Period_1, PRICE_CLOSE, nsb3);
RSIBuffer2[sh]=iRSI(NULL, TF_2, RSI_Period_2, PRICE_CLOSE, nsb);
RSIBuffer3[sh]=iRSI(NULL, TF_3, RSI_Period_3, PRICE_CLOSE, nsb2);
}
}
//+------------------------------------------------------------------+
Comments