This tool is designed to analyze the relationships between different currency pairs to identify specific price levels on your trading chart. Instead of looking at a single currency pair in isolation, the script utilizes a concept of "triangulation" based on a predefined list of connected markets.
How the Logic Works
1. Currency Relationship Mapping The core of the script is a database of 14 specific groups. Each group consists of three different currency pairs that are mathematically linked to one another (for example, if you are trading one pair, there are two other specific pairs that influence its value).
2. Real-Time Monitoring The script runs in a continuous loop. Every few milliseconds, it refreshes the current market data and checks which currency pair you are currently viewing on your screen. It then scans its internal database to see if your current pair belongs to any of the 14 predefined groups.
3. Mathematical Level Calculation When the script identifies that your current pair is part of a group, it performs a series of calculations:
- It fetches the real-time "Bid" and "Ask" prices for all three pairs in that specific group.
- It calculates the average price for each.
- Using a mathematical formula, it determines a specific "equilibrium level" based on how those three currencies interact with each other.
4. Visual Representation Once the script calculates this specific level, it automatically draws a horizontal line on your chart. This line represents a calculated price point derived from the movements of the related currency pairs.
- Dynamic Updates: Because the market is always moving, the script constantly recalculates this level. If the price level changes, the script deletes the old line and redraws a new one at the updated position to ensure the information remains current.
- Visual Distinction: Each of the 14 groups is assigned a specific color (such as Yellow, Orange, Pink, etc.), allowing you to quickly distinguish between different relationship types on your chart.
Summary for the User
In simple terms, this script tells you: "Based on how these three related currencies are behaving together right now, here is the specific price level you should be watching." It takes the complexity of multi-pair analysis and simplifies it into a single, visible horizontal line on your trading screen.
//+------------------------------------------------------------------+
//| Price Predictor.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
string pairs[14][3]={
"EURJPY","EURAUD","AUDJPY",//1 d
"EURJPY","EURCHF","CHFJPY",//6 h, inv
"EURJPY","EURGBP","GBPJPY",//12 inv
"EURJPY","EURUSD","USDJPY",//14
"AUDJPY","AUDUSD","USDJPY",//2 d
"EURUSD","EURAUD","AUDUSD",//3 d
"EURUSD","EURGBP","GBPUSD",//13
"USDJPY","USDCHF","CHFJPY",//8
"GBPJPY","GBPCHF","CHFJPY",//7 inv
"GBPJPY","GBPUSD","USDJPY",//14
"EURCAD","EURUSD","USDCAD",//9 inv
"EURCHF","EURGBP","GBPCHF",//10 inv
"EURCHF","EURUSD","USDCHF",//11 inv
"GBPCHF","GBPUSD","USDCHF",//15
};
int itn;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
start();
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
while(true){
RefreshRates();
main();
itn++;
Sleep(100);
}
//----
return(0);
}
//+------------------------------------------------------------------+
void main(){
color col[]={Yellow,Orange,Pink,YellowGreen,Purple,Red};
int match[];int c;
for(int i=0;i<14;i++){
for(int y=0;y<3;y++){
if(pairs[i][y]==Symbol()){
c++;
ArrayResize(match,c);
match[c-1]=i;
}
}
}
c=0;
int size=ArraySize(match);
/*for(i=0;i<size;i++){
Comment("ring found ",match[i],"\n\n",
pairs[match[i]][0]," ",
pairs[match[i]][1]," ",
pairs[match[i]][2]," ");
Sleep(2000);
}
*/
Comment("\nMatches = ",size,"\nIterations = ",itn);
for(i=0;i<size;i++){
double level=0;
double pr1=(MarketInfo(pairs[match[i]][0],MODE_BID) + MarketInfo(pairs[match[i]][0],MODE_ASK)) / 2;
double pr2=(MarketInfo(pairs[match[i]][1],MODE_BID) + MarketInfo(pairs[match[i]][1],MODE_ASK)) / 2;
double pr3=(MarketInfo(pairs[match[i]][2],MODE_BID) + MarketInfo(pairs[match[i]][2],MODE_ASK)) / 2;
pr1=1/pr1;
for(y=0;y<3;y++){
if(Symbol()==pairs[match[i]][y]){
c++;
if(y==0){
level=1/(pr2*pr3);
level=1/level;
break;
}
if(y==1){
level=1/(pr1*pr3);
break;
}
if(y==2){
level=1/(pr1*pr2);
break;
}
}
}
//level=NormalizeDouble(level,Digits);
//level+=i*Point;
string name=Symbol()+DoubleToStr(i,0);
drawLine(level,name,col[i],1);
}
}
void drawLine(double lvl,string name, color Col,int type){
if(ObjectFind(name) != 0){
ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
if(type == 1)
ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
else
ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name, OBJPROP_COLOR, Col);
ObjectSet(name,OBJPROP_WIDTH,1);
}else{
ObjectDelete(name);
ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
if(type == 1)
ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
else
ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name, OBJPROP_COLOR, Col);
ObjectSet(name,OBJPROP_WIDTH,1);
}
}
Comments