xMeterMTF_Ind
Download scriptThe xMeterMTF Indicator is designed to provide a visual representation of the relative strength of major currencies within the forex market. Rather than looking at a single price movement, it analyzes how different currency pairs are performing over a specific period to determine which "base" currencies are currently dominant and which are being pressured.
Core Logic Overview
The script operates by evaluating several major currency pairs (such as EURUSD, GBPUSD, USDJPY, etc.) simultaneously. It calculates a "strength grade" for each pair based on where the current market price sits relative to its recent highs and lows.
By looking at these ratios, the tool determines the "power" of each individual currency. For example, if a currency is consistently hitting new highs across multiple different pairs, it is identified as being strong; if it is consistently hitting lows, it is identified as weak.
How the Calculation Works
To produce the final visual data, the script follows these logic steps:
- Data Collection: The tool monitors 12 specific currency pairs and identifies the "Major" currencies involved (USD, EUR, GBP, CHF, CAD, AUD, and JPY).
- Range Analysis: For every pair, it calculates the distance between the highest price and the lowest price over a predefined period (the "Range").
- Positioning: It determines where the current price is sitting within that range. A price near the top of the daily range suggests strength, while a price near the bottom suggests weakness.
- Grading System: Each pair is assigned a numerical grade based on its position in the range. These grades are mapped to a specific table to ensure consistent scaling across different types of currency pairs (handling the difference between standard pairs and JPY-based pairs automatically).
- Currency Aggregation: This is the most critical step. Instead of just showing you the strength of "EURUSD," the script looks at every pair where "EUR" or "USD" appears. It averages the strength scores of all those appearances to create a single, unified "Meter" for that specific currency.
Visual Output
The result of this logic is a set of lines on your chart representing the "Power Meter" for each of the 7 major currencies. This allows you to see at a glance:
- Which currencies are currently leading the market.
- Which currencies are under significant pressure.
- The relative balance of power between different global economies.
Essentially, it transforms complex, multi-pair price action into a simplified "power ranking" of the world's major currencies.
/*
xMeterMTF_Ind.mq4
Copyright © 2007, MetaQuotes Software Corp.
Price Meter System ©GPL
Hartono Setiono
5/17/2007 Redsigned based on xMeter_mini.mq4 indicator
*/
#property copyright "x Meter System ©GPL"
#property link "forex-tsd dot com"
#include <stdlib.mqh>
#include <stderror.mqh>
#define ARRSIZE 12 // number of pairs !!!DON'T CHANGE THIS NUMBER!!!
#define PAIRSIZE 7 // number of currencies !!!DON'T CHANGE THIS NUMBER!!!
#define TABSIZE 10 // scale of currency's power !!!DON'T CHANGE THIS NUMBER!!!
#define ORDER 2 // available type of order !!!DON'T CHANGE THIS NUMBER!!!
extern bool AccountIsIBFXmini = false;
extern int mTimeFrame = 1440;
extern int mPeriod=3;
string aPair[ARRSIZE] = {"EURUSD","GBPUSD","AUDUSD","USDJPY","USDCHF","USDCAD",
"EURJPY","EURGBP","EURCHF","EURAUD","GBPJPY","GBPCHF"};
string aMajor[PAIRSIZE] = {"USD","EUR","GBP","CHF","CAD","AUD","JPY"};
color aColor[PAIRSIZE] = {Red, Yellow, DarkOrange, DodgerBlue, Aqua, Magenta, DeepPink};
int aMajorPos[PAIRSIZE] = {130, 110, 90, 70, 50, 30, 10};
string aOrder[ORDER] = {"BUY ","SELL "};
int aTable[TABSIZE] = {0,3,10,25,40,50,60,75,90,97}; // grade table for currency's power
double curr1[];
double curr2[];
double curr3[];
double curr4[];
double curr5[];
double curr6[];
double curr7[];
//+------------------------------------------------------------------+
// expert initialization function |
//+------------------------------------------------------------------+
int init()
{
int i;
IndicatorBuffers(PAIRSIZE);
SetIndexBuffer(0,curr1);
SetIndexBuffer(1,curr2);
SetIndexBuffer(2,curr3);
SetIndexBuffer(3,curr4);
SetIndexBuffer(4,curr5);
SetIndexBuffer(5,curr6);
SetIndexBuffer(6,curr7);
for(i=0; i<PAIRSIZE; i++)
{
SetIndexStyle(i, DRAW_LINE, STYLE_SOLID, 1, aColor[i]);
SetIndexLabel(i, aPair[i]);
}
return(0); // end of init function
}
//+------------------------------------------------------------------+
// expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0); // end of deinit function
}
//+------------------------------------------------------------------+
// expert start function |
//+------------------------------------------------------------------+
int start()
{
double aMeter[PAIRSIZE];
double aHigh[ARRSIZE];
double aLow[ARRSIZE];
double aBid[ARRSIZE];
double aAsk[ARRSIZE];
double aRatio[ARRSIZE];
double aRange[ARRSIZE];
double aLookup[ARRSIZE];
double aStrength[ARRSIZE];
double point;
int index, pindex, cnt;
string mySymbol;
double cmeter;
int i,j,limit,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++)
{
for (index = 0; index < ARRSIZE; index++) // initialize all pairs required value
{
RefreshRates(); // refresh all currency's instrument
if (AccountIsIBFXmini)
mySymbol = aPair[index]+'m'; // Add "m for IBFX mini
else
mySymbol = aPair[index];
point = GetPoint(mySymbol); // get a point basis
aHigh[index] = iHigh(mySymbol,mTimeFrame,iHighest(mySymbol,mTimeFrame,MODE_HIGH,mPeriod,0)); // find highest
aLow[index] = iLow(mySymbol,mTimeFrame,iLowest(mySymbol,mTimeFrame,MODE_LOW,mPeriod,0)); // find lowest
aBid[index] = MarketInfo(mySymbol,MODE_BID); // set a last bid
aAsk[index] = MarketInfo(mySymbol,MODE_ASK); // set a last ask
aRange[index] = MathMax((aHigh[index]-aLow[index])/point,1); // calculate range today
aRatio[index] = (aBid[index]-aLow[index])/aRange[index]/point; // calculate pair ratio
aLookup[index] = iLookup(aRatio[index]*100); // set a pair grade
aStrength[index] = 9-aLookup[index]; // set a pair strengh
}
// calculate all currencies meter
for (pindex=0; pindex<PAIRSIZE; pindex++)
{
cnt=0;
cmeter=0;
for (index = 0; index < ARRSIZE; index++) // initialize all pairs required value
{
if (StringSubstr(aPair[index],0,3)==aMajor[pindex])
{
cnt++;
cmeter = cmeter + aLookup[index];
}
if (StringSubstr(aPair[index],3,3)==aMajor[pindex])
{
cnt++;
cmeter = cmeter + aStrength[index];
}
if (cnt>0) aMeter[pindex]=NormalizeDouble(cmeter / cnt,1); else aMeter[pindex]=-1;
//Print(aMajor[pindex],":",StringSubstr(aPair[index],1,3),":",StringSubstr(aPair[index],4,3),":",cmeter,":",cnt);
}
}
}
return(0); // end of start funtion
}
//+------------------------------------------------------------------+
// expert custom function |
//+------------------------------------------------------------------+
double GetPoint(string mSymbol)
{
double myPoint = 0.0001, YenPoint = 0.01;
string mySymbol;
if (StringSubstr(mySymbol,3,3) == "JPY") return (YenPoint);
return(myPoint);
}
int iLookup(double ratio) // this function will return a grade value
{ // based on its power.
int index=-1, i;
if (ratio <= aTable[0]) index = 0;
else {
for (i=1; i<TABSIZE; i++) if(ratio < aTable[i]) {index=i-1; break; }
if(index==-1) index=9;
}
return(index); // end of iLookup function
}
Comments