Predictive_Price_FPIv2_001
Download scriptThis script is designed to identify specific price correlation points by analyzing the relationship between different currency pairs. It functions as a visual aid for traders who want to see "equilibrium" levels—mathematical intersections where multiple currency values interact.
Core Methodology
The logic is based on the concept of "triangulation." The script contains a pre-defined database of currency groups. Each group consists of three specific pairs that are mathematically linked. For example, if you have an exchange rate between Currency A and B, and another between B and C, there is a mathematical relationship that dictates what the price should be between A and C.
How the Logic Works
- Pair Identification: The script constantly scans the market to see which currency pair you are currently viewing on your chart. It checks its internal database to see if your current pair belongs to any of the predefined "triangles" or "rings."
- Real-Time Calculation: Once it identifies that your current pair is part of a group, it fetches the live market prices for the other two pairs in that group simultaneously.
- Equilibrium Determination: It performs a calculation to determine the "theoretical" price level based on those other two pairs. Essentially, it calculates where the price should be if the currency values were perfectly balanced relative to one another.
- Visual Mapping: The script then takes this calculated price and automatically draws a horizontal line on your chart. This line serves as a visual reference point.
- Dynamic Updating: The script runs in a continuous loop, refreshing the market data and repositioning these lines constantly. If the prices of the linked pairs move, the "predicted" line moves with them in real-time.
User Experience
Instead of making you manually calculate complex currency cross-rates, the script does the heavy lifting. When you switch between different charts (like EURUSD or GBPJPY), the script automatically detects the relevant mathematical group and displays a colored horizontal line. This allows a trader to see at a glance whether the current price is deviating from its mathematical "ring" or if it is sitting at a point of balance.
//+------------------------------------------------------------------+
//| 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};
string colst[]={"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);
}
string k;
for(i=0;i<size;i++){
k=k+"\n";
for(y=0;y<3;y++){
k=k+pairs[match[i]][y]+" ";
}
k=k+StringConcatenate(" ( ",colst[i]," )");
}
Comment("RINGS:\n",k);
}
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