MIndexq30AUG05t
Download scriptThis tool is designed to provide traders with a unified view of the global currency market by creating a customized "synthetic index." Instead of looking at individual currency pairs in isolation, this script calculates a broader market movement based on the relationship between several major global currencies.
How the Logic Works
The core objective of this indicator is to determine the relative strength or weight of the US Dollar (USD) against a basket of major international currencies. Here is the step-by-step breakdown of its logic:
1. Data Collection The script automatically gathers real-time closing price data from six specific currency pairs:
- EUR/USD (Euro)
- GBP/USD (British Pound)
- AUD/USD (Australian Dollar)
- USD/CHF (Swiss Franc)
- USD/JPY (Japanese Yen)
- USD/CAD (Canadian Dollar)
2. Calculating the Base Index To find a "neutral" market baseline, the script performs a mathematical calculation across all six of these pairs simultaneously. It multiplies the values of some pairs and divides by others, applying a geometric mean (specifically, a seventh root). This results in a single numerical value that represents the collective movement of these major currencies relative to one another.
3. Customizing for Your Preferred Currency While the primary calculation is based on the US Dollar, the tool allows you to view this market data through the lens of your specific trading currency. Depending on which currency you select in the settings (such as EUR, GBP, JPY, etc.), the script adjusts the final output:
- If you choose USD, it shows the raw synthetic index.
- If you choose a currency like EUR or GBP, it converts the index to reflect that specific currency's value relative to the rest of the basket.
- If you choose a currency where the USD is the "quote" (like JPY or CHF), it performs a division to show the inverse relationship accurately.
Summary for the Trader
Essentially, this script filters out the "noise" of individual pairs to show you a broader trend. By observing this indicator, you can see the underlying momentum of the global forex market as a single moving line, adjusted specifically to the currency you are currently trading.
//+------------------------------------------------------------------+
//| 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 Currency="USD";
//----
double EurUsd[],UsdChf[],GbpUsd[],UsdJpy[],AudUsd[],UsdCad[];
double Idx[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName(Currency);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Idx);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
//----
double USD;
//----
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit--;
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");
limit=MathMin(limit,ArraySize(EurUsd));
limit=MathMin(limit,ArraySize(GbpUsd));
limit=MathMin(limit,ArraySize(AudUsd));
limit=MathMin(limit,ArraySize(UsdChf));
limit=MathMin(limit,ArraySize(UsdJpy));
limit=MathMin(limit,ArraySize(UsdCad));
for(int i=0; i<limit; i++)
{
USD=MathPow(UsdChf[i]*UsdJpy[i]*UsdCad[i]/EurUsd[i]/GbpUsd[i]/AudUsd[i],1./7.);
if(Currency=="USD") Idx[i]=USD;
if(Currency=="EUR") Idx[i]=USD*EurUsd[i];
if(Currency=="GBP") Idx[i]=USD*GbpUsd[i];
if(Currency=="AUD") Idx[i]=USD*AudUsd[i];
if(Currency=="CHF") Idx[i]=USD/UsdChf[i];
if(Currency=="JPY") Idx[i]=USD/UsdJpy[i];
if(Currency=="CAD") Idx[i]=USD/UsdCad[i];
}
return(0);
}
//+------------------------------------------------------------------+
Comments