ytg_Def_RSI_3_Symbol
Download scriptThis script is designed as a multi-currency analysis tool that tracks the relationship between three different currency pairs simultaneously. Instead of looking at a single market in isolation, it calculates the "momentum gap" across three specific symbols (defaulting to EURUSD, EURGBP, and EURJPY) and displays them on a single visual chart.
Core Logic Overview
The tool operates through a three-step mathematical process:
1. Dual Relative Strength Index (RSI) Calculation For each of the three currency pairs, the script calculates two different RSI values at the same time. The RSI is a standard technical indicator used to measure the speed and change of price movements. By using two different "periods" (timeframes), the script can compare short-term momentum against long-term momentum for every individual pair.
2. Momentum Difference Calculation Once the two RSI values are gathered for a specific currency, the script subtracts the long-term value from the short-term value. This creates a "difference" value.
- This tells the user how much the price is accelerating or decelerating relative to its historical average.
- If the result is positive, it indicates strength in the shorter timeframe; if negative, it suggests a cooling off compared to the longer trend.
3. Smoothing and Visualization Finally, the script applies a Moving Average (MA) to those "difference" values. This is a smoothing technique used to filter out market noise and minor price fluctuations. The end result is three distinct lines on your chart:
- Line 1: The smoothed momentum difference for the first pair.
- Line 2: The smoothed momentum difference for the second pair.
- Line 3: The smoothed momentum difference for the third pair.
How to Interpret the Results
The script provides a high-level overview of market "heat." By observing how these three lines move in relation to each other and the zero-line, a trader can identify:
- Correlations: Whether multiple currency pairs are reacting to news or trends in the same direction simultaneously.
- Divergences: If one currency pair is showing significantly different momentum behavior than the others.
- Trend Strength: The distance of the lines from the zero-point helps determine how aggressively a specific pair is moving compared to its historical baseline.
//+------------------------------------------------------------------+
//| ytg_Def_RSI_3_Symbol.mq4 |
//| Yuriy Tokman |
//| yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link "yuriytokman@gmail.com"
//íó åñëè ïðîùå çàïóëèòü â îäíî îêíî òðè ìóëüòè ñ íàñòðîéêàìè
//1 EUR-USD
//2 EURGBP
//3 EURJPY
//åñëè âñå òðè â ñîñòîÿíèè ïåðåêóïëåííîñòè çíà÷èò Áàé è íàîáîðîò
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_level1 0
#property indicator_level2 5
#property indicator_level3 -5
extern string Symbol_1 = "EURUSD";
extern string Symbol_2 = "EURGBP";
extern string Symbol_3 = "EURJPY";
extern int RSI_1_Period = 14;//ïåðèîä ïåðâîãî èíäèêàòîðà ÐÑÈ
extern int RSI_2_Period = 28;//ïåðèîä âòîðîãî èíäèêàòîðà ÐÑÈ
extern int applied_price = 0;//èñïîëüçóåìàÿ öåíà 0-6
extern int ma_period = 14;//ïåðèîä ñãëàæèâàíèÿ
extern int ma_method = 0;//ìåòîä ñãëàæèâàíèÿ 0-3
double buf[];
double MA_buf[];
double buf2[];
double MA_buf2[];
double buf3[];
double MA_buf3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0, buf);
SetIndexStyle(4,DRAW_NONE);
SetIndexBuffer(4,MA_buf);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1, buf2);
SetIndexStyle(3,DRAW_NONE);
SetIndexBuffer(3,MA_buf2);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(2, buf3);
SetIndexStyle(5,DRAW_NONE);
SetIndexBuffer(5,MA_buf3);
IndicatorShortName("ytg_Def_RSI_3_Symbol");
Comment("yuriytokman@gmail.com");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
double RSI_1, RSI_2, RSI_12, RSI_22, RSI_13, RSI_23;
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
RSI_1 = iRSI(Symbol_1,0,RSI_1_Period,applied_price,i);
RSI_2 = iRSI(Symbol_1,0,RSI_2_Period,applied_price,i);
MA_buf[i] = (RSI_1-RSI_2);
RSI_12 = iRSI(Symbol_2,0,RSI_1_Period,applied_price,i);
RSI_22 = iRSI(Symbol_2,0,RSI_2_Period,applied_price,i);
MA_buf2[i] = (RSI_12-RSI_22);
RSI_13 = iRSI(Symbol_3,0,RSI_1_Period,applied_price,i);
RSI_23 = iRSI(Symbol_3,0,RSI_2_Period,applied_price,i);
MA_buf3[i] = (RSI_13-RSI_23);
}
for(i=limit; i>=0; i--)
{
buf[i] = iMAOnArray(MA_buf,0,ma_period,0,ma_method,i);
buf2[i] = iMAOnArray(MA_buf2,0,ma_period,0,ma_method,i);
buf3[i] = iMAOnArray(MA_buf3,0,ma_period,0,ma_method,i);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments