MultiPairTrend
Download scriptMarket Dynamics Overview: MultiPair Trend Analysis
This script is designed to provide a comprehensive visual overview of the relationships between major global currencies. Instead of looking at a single currency pair in isolation, the tool analyzes how various major assets—specifically the Euro (EUR), British Pound (GBP), Australian Dollar (AUD), Swiss Franc (CHF), Japanese Yen (JPY), Canadian Dollar (CAD), and the US Dollar (USD)—move in relation to one another.
How the Logic Works
1. Momentum Tracking via Moving Averages The core of the logic relies on calculating the difference between two different types of "Moving Averages" for each currency. By comparing a short-term average price against a slightly longer-term average price, the script identifies the momentum of each individual currency.
- For most currencies, it measures how much the recent price is pulling away from its historical trend.
- For specific pairs (like the Swiss Franc and Canadian Dollar), the logic is mirrored to ensure that the "strength" or "weakness" of the movement is captured consistently across all assets.
2. Normalization for Comparison Because different currencies have vastly different price values (for example, the Japanese Yen is priced much differently than the Euro), the script performs internal scaling and mathematical adjustments. This ensures that each currency's movement is represented on a comparable scale, allowing you to see relative strengths without being distracted by the raw price of the assets.
3. Synthetic USD Strength Calculation One of the most unique features of this logic is how it determines the position of the US Dollar. Rather than just looking at one pair, the script takes the combined data from the other major currencies and calculates a synthetic value for the USD. It effectively "sums up" the market behavior of the other six major currencies to provide a holistic view of where the US Dollar stands in the global market.
Visual Representation
The script generates seven distinct lines on a separate window:
- Six individual lines represent the specific momentum trends of the Euro, Pound, Australian Dollar, Swiss Franc, Japanese Yen, and Canadian Dollar.
- A seventh line represents the calculated trend of the US Dollar based on the aggregate data of the others.
By observing these lines together, a user can see at a glance which currencies are leading the market, which are lagging, and how the overall balance of power is shifting between the major global economies.
//+------------------------------------------------------------------+
//| MultiPairTrend.mq4 |
//+------------------------------------------------------------------+
#property copyright "Alexander Arzumanov"
#property link "arzuma@helios.ru arzuma@megalog.ru"
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Orange
#property indicator_color4 White
#property indicator_color5 Yellow
#property indicator_color6 Aqua
#property indicator_color7 Lime
double EUR,GBP,AUD,CHF,JPY,CAD,USD,M;
extern int PerAvr=5;
extern double K=0.6;
double Idx[],Idx1[],Idx2[],Idx3[],Idx4[],Idx5[],Idx6[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,Idx);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(1,Idx1);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(2,Idx2);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(3,Idx3);
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(4,Idx4);
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(5,Idx5);
SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,3);
SetIndexBuffer(6,Idx6);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
int M=NormalizeDouble(1+K,0);
EUR=(iMA("EURUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("EURUSD",0,PerAvr*M,0,MODE_LWMA,PRICE_CLOSE,i));
GBP=(iMA("GBPUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("GBPUSD",0,PerAvr*M,0,MODE_LWMA,PRICE_CLOSE,i));
AUD=(iMA("AUDUSD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("AUDUSD",0,PerAvr*M,0,MODE_LWMA,PRICE_CLOSE,i));
CHF=(iMA("USDCHF",0,PerAvr*M,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("USDCHF",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i));
JPY=(iMA("USDJPY",0,PerAvr*M,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("USDJPY",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i))/100;
CAD=(iMA("USDCAD",0,PerAvr*M,0,MODE_LWMA,PRICE_CLOSE,i)-iMA("USDCAD",0,PerAvr,0,MODE_LWMA,PRICE_CLOSE,i));
USD=-(EUR+GBP+AUD+CHF+CAD+JPY)/6;
Idx[i] = EUR;
Idx1[i] = GBP;
Idx2[i] = AUD;
Idx3[i] = CHF;
Idx4[i] = JPY;
Idx5[i] = CAD;
Idx6[i] = USD;
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Comments