The RSI 2TF Oscillator is a custom trading indicator designed to help traders identify market momentum by comparing two different timeframes simultaneously. While standard indicators usually look at only one perspective of the market, this tool provides a dual-layered view to help users understand the relationship between short-term price action and longer-term trends.
How It Works
The core logic of this script revolves around the Relative Strength Index (RSI), a popular momentum tool that measures the speed and change of price movements. Instead of showing you just one RSI line, this indicator calculates and plots two distinct values:
- Current Timeframe Analysis: The first line tracks the RSI based on the specific chart timeframe you are currently viewing (e.g., a 5-minute or 15-minute chart). This represents the immediate "pulse" of the market.
- Higher Timeframe Analysis: The second line automatically looks ahead to a larger timeframe that you define in the settings (such as the 1-hour chart). It syncs this larger data point back onto your current chart so you can see what the "big picture" trend looks like without switching windows.
Visual Representation
The indicator appears in a separate window below your main price chart, scaled from 0 to 100. It utilizes two distinct lines:
- Blue Line: Represents the RSI of your current active timeframe.
- Salmon Line: Represents the RSI of the higher timeframe you selected.
By observing these two lines together, traders can see if the short-term momentum is moving in harmony with the larger trend or if it is diverging. For instance, if the short-term line is pushing upward while the longer-term line remains flat or moves down, it may signal a temporary fluctuation rather than a sustained trend change.
Key Settings
- Period: This determines the look-back window for the RSI calculation (the default is 14). A smaller number makes the indicator more sensitive to recent price changes, while a larger number smooths out the data.
- New TimeFrame: This allows you to choose which higher timeframe you want to overlay on your current chart. By adjusting this, you can customize how "far ahead" the second line looks into the market's history.
//+------------------------------------------------------------------+
//| RSI 2TF Oscillyator.mq4 |
//| Copyright © 2016, assurkov, Alexey Surkov |
//| http://www.assurkov.ru/ |
//+------------------------------------------------------------------+
#property strict
#property copyright "Copyright © 2016, www.assurkov.ru, Alexey Surkov"
#property link "https://www.mql5.com/ru/market/product/15565"
#property version "1.00"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 20
#property indicator_level2 80
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Salmon
#property indicator_width1 1
#property indicator_width2 2
//----
extern int Period=14;
input int NewTimeFrame=60;
//---- buffers
double Buffer1[],Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string sShortName;
SetIndexBuffer(0,Buffer1);
SetIndexStyle(0,DRAW_LINE);
sShortName="RSI 2TF"+"("+string(Period)+")";
IndicatorShortName(sShortName);
SetIndexLabel(0,sShortName);
SetIndexDrawBegin(0,14);
SetIndexBuffer(1,Buffer2);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0)
{
Print("Indicator Error (Counted bars < 0)!");
return(-1);
}
if(Bars<17)
{
Print("Indicator Error (Bars < 12)!");
return(-1);
}
int limit=Bars-17;
if(counted_bars>17)
{
limit=Bars-counted_bars;
}
for(int i=limit; i>=0; i --)
{
Buffer1[i]=EMPTY_VALUE;
Buffer2[i]=EMPTY_VALUE;
Buffer1[i]=iRSI("0",0,Period,PRICE_CLOSE,i);
int iNext1=iBarShift(NULL,NewTimeFrame,iTime(NULL,0,i));
Buffer2[i]=iRSI("0",NewTimeFrame,Period,PRICE_CLOSE,iNext1);
}
//--------------------------------------------------------------------
return (0);
}
//--------------------------------------------------------------------
Comments