Correl[i]_1_v1
Download scriptThis script is designed to calculate and display a composite "Market Index" based on a basket of major currencies. Instead of looking at just one pair, it provides a broader view of market sentiment by aggregating the movements of several global currencies simultaneously.
How it Works
The logic follows a three-step process to provide you with a customized view of the market:
1. Data Collection The tool identifies six primary currency pairs involving major global markets (EUR, GBP, AUD, CHF, JPY, and CAD) against the US Dollar. It pulls the closing prices for all these pairs in real-time.
2. The "USD" Base Calculation The script performs a mathematical normalization of these six pairs. It treats them as a single basket to derive a geometric mean—essentially a "weighted average" price. This represents the core strength or weakness of the US Dollar relative to this specific group of global currencies.
3. Currency Customization Once the base value is calculated, the script allows you to choose which currency you want to track as your primary focus. Depending on what you select in the settings (such as USD, EUR, JPY, etc.), the script performs a final conversion:
- For most currencies, it multiplies or divides the base value by the specific exchange rate of that currency.
- This creates a single line on your chart that reflects the relative performance of your chosen currency against the entire basket of major global markets.
Key Takeaway for Traders
Rather than watching individual charts to see where the market is moving, this indicator simplifies the data into one visual line. It helps you see if your chosen currency is gaining or losing ground against a broad spectrum of international markets at once, effectively smoothing out the "noise" of individual pairs.
//+------------------------------------------------------------------+
//| MIndex.mq4 |
//| Copyright © 2005, Yuri Makarov. |
//| http://mak.tradersmind.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Yuri Makarov."
#property link "http://mak.tradersmind.com"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 OrangeRed
//----
extern string Curency="USD";
//----
double EurUsd[],UsdChf[],GbpUsd[],UsdJpy[],AudUsd[],UsdCad[];
double Idx[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName(Curency);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Idx);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void start()
{
ArrayCopySeries(EurUsd,MODE_CLOSE,"EURUSD");
ArrayCopySeries(GbpUsd,MODE_CLOSE,"GBPUSD");
ArrayCopySeries(AudUsd,MODE_CLOSE,"AUDUSD");
ArrayCopySeries(UsdChf,MODE_CLOSE,"USDCHF");
ArrayCopySeries(UsdJpy,MODE_CLOSE,"USDJPY");
ArrayCopySeries(UsdCad,MODE_CLOSE,"USDCAD");
//----
int counted_bars=IndicatorCounted();
double USD;
//----
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(int i=0; i<limit; i++)
{
USD=MathPow(UsdChf[i]*UsdJpy[i]*UsdCad[i]/EurUsd[i]/GbpUsd[i]/AudUsd[i],1./7.);
if (Curency=="USD") Idx[i]=USD;
if (Curency=="EUR") Idx[i]=USD*EurUsd[i];
if (Curency=="GBP") Idx[i]=USD*GbpUsd[i];
if (Curency=="AUD") Idx[i]=USD*AudUsd[i];
if (Curency=="CHF") Idx[i]=USD/UsdChf[i];
if (Curency=="JPY") Idx[i]=USD/UsdJpy[i];
if (Curency=="CAD") Idx[i]=USD/UsdCad[i];
}
}
//+------------------------------------------------------------------+
Comments