ytg_Change_Price_Percent
Download scriptThis script is designed as a real-time market monitoring tool for MetaTrader users who need to keep a constant eye on the performance of multiple currency pairs simultaneously. Instead of forcing you to switch between different charts to see how various markets are moving, this tool pulls that data into a single, organized visual display on your primary screen.
How it Works
The logic of the script can be broken down into three main stages:
1. Data Selection and Tracking The tool is configured to monitor four specific currency pairs (such as EURUSD, USDCHF, GBPUSD, and USDJPY). For each of these pairs, the script looks at two primary data points:
- The Current Market Price: What the price is right now.
- The Previous Day's Closing Price: Where the market ended yesterday.
2. Percentage Calculation Rather than just showing you the raw price (which can be hard to interpret at a glance), the script calculates the percentage change. It determines exactly how much the current price has moved up or down relative to yesterday's close. This allows you to see the magnitude of the market move immediately—for example, seeing a "0.5% increase" is often more useful for a trader than seeing a complex decimal price.
3. Visual Feedback and Organization Once the calculations are complete, the script updates your trading screen automatically with a clean text display:
- Dynamic Labeling: It lists the currency pair names followed by their calculated percentage change.
- Color Coding: To provide an instant visual cue, the script changes the text color based on performance. If the price is higher than yesterday's close, the text appears in one color (Lime); if it is lower, it switches to another (Red).
- Positioning: The information is stacked neatly in a specific corner of your chart, ensuring that all four markets are visible in a compact area without cluttering your workspace.
Summary for the User
Essentially, this script acts as a "Live Dashboard." It performs the math behind the scenes to tell you exactly how much each currency has moved since yesterday’s session ended, highlighting the winners and losers in different colors so you can make informed decisions quickly.
//+------------------------------------------------------------------+
//| ytg_Change_Price_Percent.mq4 |
//| Copyright © 2009, Yuriy Tokman |
//| yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Yuriy Tokman"
#property link "yuriytokman@gmail.com"
#property indicator_chart_window
extern string Symbol1 = "EURUSD";
extern string Symbol2 = "USDCHF";
extern string Symbol3 = "GBPUSD";
extern string Symbol4 = "USDJPY";
extern int Ðàçìåð_øðèôòà = 10;
extern int Óãîë_ïðèâÿçêè = 1;
extern color color_up = Lime;
extern color color_down = Red;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
ObjectCreate("Symbol1",OBJ_LABEL,0,0,0,0,0);
ObjectCreate("Symbol2",OBJ_LABEL,0,0,0,0,0);
ObjectCreate("Symbol3",OBJ_LABEL,0,0,0,0,0);
ObjectCreate("Symbol4",OBJ_LABEL,0,0,0,0,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete ("Symbol1");
ObjectDelete ("Symbol2");
ObjectDelete ("Symbol3");
ObjectDelete ("Symbol4");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
double sym_1 =(MarketInfo(Symbol1,MODE_BID) - iClose(Symbol1,PERIOD_D1,1))*100/iClose(Symbol1,PERIOD_D1,1);
double sym_2 =(MarketInfo(Symbol2,MODE_BID) - iClose(Symbol2,PERIOD_D1,1))*100/iClose(Symbol2,PERIOD_D1,1);
double sym_3 =(MarketInfo(Symbol3,MODE_BID) - iClose(Symbol3,PERIOD_D1,1))*100/iClose(Symbol3,PERIOD_D1,1);
double sym_4 =(MarketInfo(Symbol4,MODE_BID) - iClose(Symbol4,PERIOD_D1,1))*100/iClose(Symbol4,PERIOD_D1,1);
//----
color color_1 = 0, color_2 = 0, color_3 = 0, color_4 = 0;
if(sym_1>0)color_1=color_up; else color_1=color_down;
if(sym_2>0)color_2=color_up; else color_2=color_down;
if(sym_3>0)color_3=color_up; else color_3=color_down;
if(sym_4>0)color_4=color_up; else color_4=color_down;
//----
string Symbol_1 =" = "+DoubleToStr(sym_1, 4)+" %";
string Symbol_2 =" = "+DoubleToStr(sym_2, 4)+" %";
string Symbol_3 =" = "+DoubleToStr(sym_3, 4)+" %";
string Symbol_4 =" = "+DoubleToStr(sym_4, 4)+" %";
//----
ObjectSetText("Symbol1",Symbol1+Symbol_1,Ðàçìåð_øðèôòà,"Arial Black",Lime);
ObjectSet("Symbol1",OBJPROP_XDISTANCE,3);
ObjectSet("Symbol1",OBJPROP_YDISTANCE,30);
ObjectSet("Symbol1",OBJPROP_COLOR,color_1);
ObjectSet("Symbol1",OBJPROP_CORNER,Óãîë_ïðèâÿçêè);
ObjectSetText("Symbol2",Symbol2+Symbol_2,Ðàçìåð_øðèôòà,"Arial Black",Lime);
ObjectSet("Symbol2",OBJPROP_XDISTANCE,3);
ObjectSet("Symbol2",OBJPROP_YDISTANCE,50);
ObjectSet("Symbol2",OBJPROP_COLOR,color_2);
ObjectSet("Symbol2",OBJPROP_CORNER,Óãîë_ïðèâÿçêè);
ObjectSetText("Symbol3",Symbol3+Symbol_3,Ðàçìåð_øðèôòà,"Arial Black",Lime);
ObjectSet("Symbol3",OBJPROP_XDISTANCE,3);
ObjectSet("Symbol3",OBJPROP_YDISTANCE,70);
ObjectSet("Symbol3",OBJPROP_COLOR,color_3);
ObjectSet("Symbol3",OBJPROP_CORNER,Óãîë_ïðèâÿçêè);
ObjectSetText("Symbol4",Symbol4+Symbol_4,Ðàçìåð_øðèôòà,"Arial Black",Lime);
ObjectSet("Symbol4",OBJPROP_XDISTANCE,3);
ObjectSet("Symbol4",OBJPROP_YDISTANCE,90);
ObjectSet("Symbol4",OBJPROP_COLOR,color_4);
ObjectSet("Symbol4",OBJPROP_CORNER,Óãîë_ïðèâÿçêè);
//----
return(0);
}
//+------------------------------------------------------------------+
Comments