RSI-2TF
Download scriptThis tool is designed to provide traders with a clearer picture of market momentum by comparing two different timeframes simultaneously on a single visual display. Instead of looking at just one set of data, it allows you to observe how the current price action relates to a larger trend.
How It Works
The logic of this script centers on the "Relative Strength Index" (RSI), a common technical indicator used to measure whether an asset is being overbought or oversold. This specific tool enhances that measurement by layering two different perspectives:
- Current Timeframe Analysis: The primary line tracks the RSI based on your current active chart (e.g., a 5-minute or 15-minute chart). This gives you immediate insight into short-term price fluctuations and "noise."
- Higher Timeframe Context: The second line calculates the RSI based on a secondary, larger timeframe (defined by the user as a 60-minute period by default). By calculating the RSI for this longer duration and mapping it onto your current chart, the tool allows you to see the "big picture" without constantly switching between different windows.
Key Features
- Dual Correlation: By displaying both lines together, you can see if the short-term momentum is moving in harmony with the long-term trend or if it is diverging. For example, it helps identify situations where the price might look like it's climbing on a small chart, while the larger timeframe shows the overall momentum is actually slowing down.
- Visual Thresholds: The indicator includes pre-set levels (30 and 70). These serve as guides to help you quickly identify when prices may be reaching extreme highs or lows relative to their historical averages.
- Customizable Range: You can choose exactly how many historical bars the tool should analyze, allowing for a cleaner display tailored to your specific trading style.
Summary for the Trader
Essentially, this script acts as a "multi-timeframe lens." It automates the process of checking a higher time interval, showing you the broader market sentiment right alongside your immediate trading data. This helps in making more informed decisions by ensuring that your short-term trades are aligned with the dominant longer-term movement.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| RSI-2TF.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//| |
//| 29.10.2005 Ìîäåðíèçàöèÿ Êèì Èãîðü Â. aka KimIV |
//| http://www.kimiv.ru |
//+------------------------------------------------------------------+
#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 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Yellow
#property indicator_level1 70
#property indicator_level2 30
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int RSI_Period_0 = 14;
extern int TF_1 = 60;
extern int RSI_Period_1 = 14;
extern int NumberOfBars = 1000; // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double RSIBuffer0[];
double RSIBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init() {
string short_name;
//---- indicator line
SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(0, RSIBuffer0);
SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(1, RSIBuffer1);
//---- name for DataWindow and indicator subwindow label
short_name="RSI("+RSI_Period_0+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
short_name="RSI("+RSI_Period_1+")";
SetIndexLabel(1,short_name);
SetIndexDrawBegin(0,RSI_Period_0);
SetIndexDrawBegin(1,RSI_Period_1);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
void start() {
int LoopBegin, sh, nsb;
if (NumberOfBars==0) LoopBegin=Bars-1;
else LoopBegin=NumberOfBars-1;
for (sh=LoopBegin; sh>=0; sh--) {
nsb=iBarShift(NULL, TF_1, Time[sh], False);
RSIBuffer0[sh]=iRSI(NULL, 0 , RSI_Period_0, PRICE_CLOSE, sh);
RSIBuffer1[sh]=iRSI(NULL, TF_1, RSI_Period_1, PRICE_CLOSE, nsb);
}
}
//+------------------------------------------------------------------+
Comments