Complex_Common__(bez linii)
Download scriptThis script is designed to provide a comprehensive overview of currency trends by calculating the relative strength of major currencies (USD, EUR, GBP, CHF, and JPY) simultaneously. Rather than looking at just one trading pair, it analyzes multiple interactions to determine which currencies are gaining or losing momentum across the broader market.
Core Logic and Functionality
Multi-Currency Analysis The primary goal of the script is to identify the "strength" of individual currencies. To do this, it performs a series of calculations involving several different trading pairs (such as EURUSD, GBPJPY, USDCHF, etc.). By comparing how these currencies move against one another, the tool calculates a net value for each specific currency:
- USD (United States Dollar)
- EUR (Euro)
- GBP (British Pound)
- CHF (Swiss Franc)
- JPY (Japanese Yen)
Dynamic Timeframe Adaptation The script is "intelligent" regarding timeframes. It contains a built-in logic system that automatically adjusts its calculation settings based on the chart period you are currently viewing. For example, it uses different mathematical weights for a 1-minute chart compared to a Monthly chart. This ensures that the data remains relevant and smooth whether you are scalping short-term moves or performing long-term trend analysis.
Moving Average Calculations The technical foundation of the script relies on comparing two different "Moving Averages." It looks at a faster moving average (representing recent price action) and a slower moving average (representing the broader trend). The difference between these two lines is used to determine momentum:
- If a currency is performing well against its peers, its value will move in one direction on the indicator.
- If it is weakening, it will move in the opposite direction.
Visual Customization and Filtering The script includes a specialized viewing mode called "OnlyPair." When enabled, the indicator becomes highly specific to your current chart:
- If you are viewing a EURUSD chart, it will primarily highlight the data for Euro and USD, hiding the others to reduce visual clutter.
- If the "OnlyPair" setting is turned off, the script displays all five currencies as distinct lines, allowing you to see the entire market's health at a glance.
Summary for the User
In simple terms, this tool acts like a "momentum dashboard." Instead of you having to manually check ten different charts to see which currency is strongest, the script does that math automatically. It aggregates all that data into five lines on a single window, showing you which currencies are leading the market and which are lagging behind in real-time.
//+------------------------------------------------------------------+
//| Complex_Common.mq4 |
//| SemSemFX@rambler.ru |
//| http://forum.alpari-idc.ru/viewtopic.php?t=46916 |
//+------------------------------------------------------------------+
#property copyright "SemSemFX@rambler.ru"
#property link "http://forum.alpari-idc.ru/viewtopic.php?t=46916"
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 White
#property indicator_color5 Yellow
//---- buffers
extern int PerFast=0, PerSlow=0;
extern bool OnlyPair=false;
extern int NBars=200;
double USD[];
double EUR[];
double GBP[];
double CHF[];
double JPY[];
//---- parameters
// for monthly
int mn_per = 12;
int mn_fast = 3;
// for weekly
int w_per = 9;
int w_fast = 3;
// for daily
int d_per = 5;
int d_fast = 3;
// for H4
int h4_per = 12;
int h4_fast = 2;
// for H1
int h1_per = 24;
int h1_fast = 8;
// for M30
int m30_per = 16;
int m30_fast = 2;
// for M15
int m15_per = 16;
int m15_fast = 4;
// for M5
int m5_per = 12;
int m5_fast = 3;
// for M1
int m1_per = 30;
int m1_fast = 10;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorShortName("USD:Green; EUR:Red; GBP:Brown; CHF:White; JPY:Yelow");
if (!OnlyPair)
{ SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,USD);
SetIndexLabel(0, "USD");
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,EUR);
SetIndexLabel(1, "EUR");
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,GBP);
SetIndexLabel(2, "GBP");
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,CHF);
SetIndexLabel(3, "CHF");
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,JPY);
SetIndexLabel(4, "JPY");
}
else
{ if ((Symbol()=="EURUSD")||(Symbol()=="GBPUSD")||(Symbol()=="USDCHF")||(Symbol()=="USDJPY"))
{SetIndexStyle(0,DRAW_LINE,0,1);} else {SetIndexStyle(0,DRAW_NONE);}
SetIndexBuffer(0,USD);
SetIndexLabel(0, "USD");
if ((Symbol()=="EURUSD")||(Symbol()=="EURGBP")||(Symbol()=="EURCHF")||(Symbol()=="EURJPY"))
{SetIndexStyle(1,DRAW_LINE,0,1);} else {SetIndexStyle(1,DRAW_NONE);}
SetIndexBuffer(1,EUR);
SetIndexLabel(1, "EUR");
if ((Symbol()=="GBPUSD")||(Symbol()=="GBPCHF")||(Symbol()=="EURGBP")||(Symbol()=="GBPJPY"))
{SetIndexStyle(2,DRAW_LINE,0,1);} else {SetIndexStyle(2,DRAW_NONE);}
SetIndexBuffer(2,GBP);
SetIndexLabel(2, "GBP");
if ((Symbol()=="USDCHF")||(Symbol()=="GBPCHF")||(Symbol()=="EURCHF")||(Symbol()=="CHFJPY"))
{SetIndexStyle(3,DRAW_LINE,0,1);} else {SetIndexStyle(3,DRAW_NONE);}
SetIndexBuffer(3,CHF);
SetIndexLabel(3, "CHF");
if ((Symbol()=="EURJPY")||(Symbol()=="GBPJPY")||(Symbol()=="CHFJPY")||(Symbol()=="USDJPY"))
{SetIndexStyle(4,DRAW_LINE,0,1);} else {SetIndexStyle(4,DRAW_NONE);}
SetIndexBuffer(4,JPY);
SetIndexLabel(4, "JPY");
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- ïðîâåðêà íà âîçìîæíûå îøèáêè
if(counted_bars<0) return(-1);
//---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
limit=NBars;
//---- îñíîâíîé öèêë
int Price=6;
int Mode=3;
int per1,per2;
if ((PerFast==0)||(PerSlow==0))
{switch(Period())
{
case 1: per1 = m1_per; per2 = m1_fast; break;
case 5: per1 = m5_per; per2 = m5_fast; break;
case 15: per1 = m15_per;per2 = m15_fast; break;
case 30: per1 = m30_per;per2 = m30_fast; break;
case 60: per1 = h1_per; per2 = h1_fast; break;
case 240: per1 = h4_per; per2 = h4_fast; break;
case 1440: per1 = d_per; per2 = d_fast; break;
case 10080: per1 = w_per; per2 = w_fast; break;
case 43200: per1 = mn_per; per2 = mn_fast; break;
}
} else {per2=PerFast; per1=PerSlow;}
for(int i=0; i<limit; i++)
{
USD[i]=
(iMA("EURUSD",0,per1,0,Mode,Price,i)-
iMA("EURUSD",0,per2,0,Mode,Price,i))*10000
+
(iMA("GBPUSD",0,per1,0,Mode,Price,i)-
iMA("GBPUSD",0,per2,0,Mode,Price,i))*10000
+
(iMA("USDCHF",0,per2,0,Mode,Price,i)-
iMA("USDCHF",0,per1,0,Mode,Price,i))*10000
+
(iMA("USDJPY",0,per2,0,Mode,Price,i)-
iMA("USDJPY",0,per1,0,Mode,Price,i))*100
;
EUR[i]=
(iMA("EURUSD",0,per2,0,Mode,Price,i)-
iMA("EURUSD",0,per1,0,Mode,Price,i))*10000
+
(iMA("EURGBP",0,per2,0,Mode,Price,i)-
iMA("EURGBP",0,per1,0,Mode,Price,i))*10000
+
(iMA("EURCHF",0,per2,0,Mode,Price,i)-
iMA("EURCHF",0,per1,0,Mode,Price,i))*10000
+
(iMA("EURJPY",0,per2,0,Mode,Price,i)-
iMA("EURJPY",0,per1,0,Mode,Price,i))*100
;
GBP[i]=
(iMA("GBPUSD",0,per2,0,Mode,Price,i)-
iMA("GBPUSD",0,per1,0,Mode,Price,i))*10000
+
(iMA("EURGBP",0,per1,0,Mode,Price,i)-
iMA("EURGBP",0,per2,0,Mode,Price,i))*10000
+
(iMA("GBPCHF",0,per2,0,Mode,Price,i)-
iMA("GBPCHF",0,per1,0,Mode,Price,i))*10000
+
(iMA("GBPJPY",0,per2,0,Mode,Price,i)-
iMA("GBPJPY",0,per1,0,Mode,Price,i))*100
;
CHF[i]=
(iMA("USDCHF",0,per1,0,Mode,Price,i)-
iMA("USDCHF",0,per2,0,Mode,Price,i))*10000
+
(iMA("EURCHF",0,per1,0,Mode,Price,i)-
iMA("EURCHF",0,per2,0,Mode,Price,i))*10000
+
(iMA("GBPCHF",0,per1,0,Mode,Price,i)-
iMA("GBPCHF",0,per2,0,Mode,Price,i))*10000
+
(iMA("CHFJPY",0,per2,0,Mode,Price,i)-
iMA("CHFJPY",0,per1,0,Mode,Price,i))*100
;
JPY[i]=
(iMA("USDJPY",0,per1,0,Mode,Price,i)-
iMA("USDJPY",0,per2,0,Mode,Price,i))*100
+
(iMA("EURJPY",0,per1,0,Mode,Price,i)-
iMA("EURJPY",0,per2,0,Mode,Price,i))*100
+
(iMA("GBPJPY",0,per1,0,Mode,Price,i)-
iMA("GBPJPY",0,per2,0,Mode,Price,i))*100
+
(iMA("CHFJPY",0,per1,0,Mode,Price,i)-
iMA("CHFJPY",0,per2,0,Mode,Price,i))*100
;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments