USD_against_all_v1
Download scriptThis script is designed to provide a visual, real-time overview of how the US Dollar (USD) is performing against several major global currencies simultaneously. Instead of looking at multiple separate charts, it consolidates this data into a single dashboard on your trading screen.
Core Functionality
The tool monitors seven specific currency pairs: JPY, CHF, CAD, NZD, AUD, GBP, and EUR. It calculates how much the USD has moved relative to each of these currencies during the current active candle (based on the timeframe you select).
How the Logic Works
- Performance Tracking: The script looks at three key price points for each currency: the opening price, the highest price reached, and the lowest price reached during the current period.
- Percentage Calculation: It determines the percentage of movement from the opening price to the current market price. If the price is rising toward the high of the candle, it calculates a positive growth percentage; if it is falling toward the low, it calculates a negative percentage.
- Visual Representation (The Histogram):
- The tool generates a visual "bar chart" for each currency.
- The height of these bars represents the strength of the move.
- The script automatically handles different currency behaviors (like JPY, CHF, and CAD) to ensure the direction of the trend is displayed correctly according to standard market conventions.
- Dynamic Color Coding: The dashboard uses a color-coded system to provide instant feedback:
- It changes colors based on whether the movement is positive or negative.
- The specific shade of the bar shifts dynamically as the percentage changes, allowing you to see at a glance which currencies are strongest and weakest.
User Experience Features
- Customizable Layout: You can adjust the horizontal and vertical distances to position the dashboard exactly where it fits best on your screen without overlapping other indicators.
- Timeframe Awareness: The script is flexible; it can display data for any timeframe (from 1 minute up to monthly charts) or automatically adapt to whatever timeframe you currently have active on your chart.
- Clean Cleanup: The script is programmed to neatly remove all its visual elements from your chart the moment you take it off, ensuring your workspace remains clean.
In short, this tool acts as a "market pulse" monitor, giving you a compact, color-coded summary of USD strength across the most important global markets at a single glance.
//+------------------------------------------------------------------+
//| |
//| USD AGAINST ALL.mg4 |
//| |
//+------------------------------------------------------------------+
#property copyright "Ñåðîâ Åâãåíèé"
#property link "vorese@yandex.ru"
#property indicator_chart_window
extern int X_DISTANCE=0; // ðàñïîëîæ. ïî ãîðèçîíòàëè
extern int Y_DISTANCE=0; // ðàñïîëîæ. ïî âåðòèêàëè
extern color tab_color=Lime; // öâåò ðàìêè
extern int text_color=16; // 0-19 îòòåíîê òåêñòà
extern string Period_="0";//M1,M5,M15,M30,H1,H4,D1,W1,MN . Åñëè 0- ïåðèîä òåêóùåãî ãðàôèêà.
//----èñïîëüçóåìûå âàë.ïàðû -------------------------------------------
string currency_pair[7]={"USDJPY","USDCHF","USDCAD","NZDUSD","AUDUSD","GBPUSD","EURUSD"};
int line_x[5]={18,32,45,148,164};// êîîðäèíàòû ãîðèçîíò.ëèíèé
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//=====================================================================
int init()
{
// ñîçäàòü ãîðèçîíò. ëèíèè
for(int x=0;x<5;x++)
{
ObjectCreate("line-x"+x,OBJ_LABEL,0,0,0);
ObjectSet("line-x"+x,OBJPROP_CORNER,3);
ObjectSet("line-x"+x,OBJPROP_XDISTANCE,X_DISTANCE+14);
ObjectSet("line-x"+x,OBJPROP_YDISTANCE,Y_DISTANCE+line_x[x]);
ObjectSetText("line-x"+x,"________________________________",7,"Verdana",tab_color);
}
//---------------------------------------------------------------------
// ñîçäàòü âåðòèêàë. ëèíèè
int c,y,r;
for(c=0;c<2;c++)
{
if(c==1)r=196;
for(y=0;y<7;y++)
{
ObjectCreate(y+"line-y"+c,OBJ_LABEL,0,0,0);
ObjectSet(y+"line-y"+c,OBJPROP_CORNER,3);
ObjectSet(y+"line-y"+c,OBJPROP_XDISTANCE,X_DISTANCE+7+r);
ObjectSet(y+"line-y"+c,OBJPROP_YDISTANCE,Y_DISTANCE+18+y*21);
ObjectSetText(y+"line-y"+c,"|",16,"Verdana",tab_color);
}
}
return(0);
}
//=====================================================================
int deinit()
{
int n,m;
for(n=0;n<7;n++) // óäàëèòü âñå îá'åêòû
{
ObjectDelete("perc"+n);
ObjectDelete("curr"+n);
if(n<5) ObjectDelete("line-x"+n);
//------
for(m=0;m<20;m++)
{
ObjectDelete(m+"gist"+n);
if(m<2) ObjectDelete(n+"line-y"+m);
}
}
ObjectDelete("text");
return(0);
}
//=====================================================================
int start()
{
int i,w,z;
for(z=0;z<7;z++)
{
for(w=0;w<20;w++)
{
ObjectDelete(w+"gist"+z); //óäàëèòü ãèñòîãðàììó ïåðåä îáíîâëåíèåì
}
string minus="";
double percent=0;
int flag=0;
int count=0;
//--------------------------------------------------------------------
// îáíîâèòü äàííûå
RefreshRates();
double bid=MarketInfo(currency_pair[z],MODE_BID);
double open=iOpen(currency_pair[z],f_Timeframe(Period_),0);
double high=iHigh(currency_pair[z],f_Timeframe(Period_),0);
double low=iLow(currency_pair[z],f_Timeframe(Period_),0);
//--------------------------------------------------------------------
// ðàñ÷åò ïðîöåíòîâ
if(bid>open && high!=open)
{
percent=(bid-open)/(high-open)*100; // ïðîö.ðàñòóùåãî áàðà
flag=1;
count=NormalizeDouble(percent/5,0);
}
else
{
if(bid<open && low!=open)
{
percent=(open-bid)/(open-low)*100; // ïðîö.ïàäàþùåãî áàðà
flag=(-1);
count=NormalizeDouble(percent/5,0);
}
}
//--------------------------------------------------------------------
if(z<3) flag=flag*(-1); // èíâåðò. "USDJPY","USDCHF","USDCAD"
if(flag==(-1)) minus="-";
if(count>=20) count=19;
//--------------------------------------------------------------------
// ïðîöåíòû
ObjectCreate("perc"+z,OBJ_LABEL,0,0,0);
ObjectSet("perc"+z,OBJPROP_CORNER,3);
ObjectSet("perc"+z,OBJPROP_XDISTANCE,X_DISTANCE+13+z*28);
ObjectSet("perc"+z,OBJPROP_YDISTANCE,Y_DISTANCE+33);
ObjectSetText("perc"+z,minus+DoubleToStr(percent,0),7,"Verdana",f_Color(text_color,flag));//16
//--------------------------------------------------------------------
// âàëþòà
ObjectCreate("curr"+z,OBJ_LABEL,0,0,0);
ObjectSet("curr"+z,OBJPROP_CORNER,3);
ObjectSet("curr"+z,OBJPROP_XDISTANCE,X_DISTANCE+15+z*28);
ObjectSet("curr"+z,OBJPROP_YDISTANCE,Y_DISTANCE+20);
ObjectSetText("curr"+z,f_Currency(z),7,"Verdana",f_Color(text_color,flag));//16
//---------------------------------------------------------------------
// ãèñòîãðàììà
for(i=0;i<=count;i++)
{
ObjectCreate(i+"gist"+z,OBJ_LABEL,0,0,0);
ObjectSet(i+"gist"+z,OBJPROP_CORNER,3);
ObjectSet(i+"gist"+z,OBJPROP_XDISTANCE,X_DISTANCE+8+z*28);
ObjectSet(i+"gist"+z,OBJPROP_YDISTANCE,Y_DISTANCE+7+i*5);
ObjectSetText(i+"gist"+z,"-",60,"Verdana",f_Color(i,flag));
}
}
//---------------------------------------------------------------------
// òåêñò
ObjectCreate("text",OBJ_LABEL,0,0,0);
ObjectSet("text",OBJPROP_CORNER,3);
ObjectSet("text",OBJPROP_XDISTANCE,X_DISTANCE+42);
ObjectSet("text",OBJPROP_YDISTANCE,Y_DISTANCE+151);
ObjectSetText("text","USD against all. Period_"+Period_,7,"Verdana",f_Color(text_color,1));
//---------------------------------------------------------------------
return(0);
}
//=====================================================================
// ôóíêöèè =
//=====================================================================
//========== âàëþòà ===================================================
string f_Currency(int curr_num)
{
string text;
switch(curr_num)
{
case 0: text="JPY";break;
case 1: text="CHF";break;
case 2: text="CAD";break;
case 3: text="NZD";break;
case 4: text="AUD";break;
case 5: text="GBP";break;
case 6: text="EUR";break;
}
return(text);
}
//============ öâåò ===================================================
color f_Color(int num,int flag)
{
color col_R,col_B,col;
switch(num)
{
case 0: col_B=C'0,10,255';col_R=C'255,10,0';break;
case 1: col_B=C'0,30,255';col_R=C'255,30,0';break;
case 2: col_B=C'0,50,255';col_R=C'255,50,0';break;
case 3: col_B=C'0,80,255';col_R=C'255,80,0';break;
case 4: col_B=C'0,100,255';col_R=C'255,100,0';break;
case 5: col_B=C'0,120,255';col_R=C'255,120,0';break;
case 6: col_B=C'0,130,255';col_R=C'255,130,0';break;
case 7: col_B=C'0,140,255';col_R=C'255,140,0';break;
case 8: col_B=C'0,150,255';col_R=C'255,150,0';break;
case 9: col_B=C'0,160,255';col_R=C'255,160,0';break;
case 10: col_B=C'0,170,255';col_R=C'255,170,0';break;
case 11: col_B=C'0,180,255';col_R=C'255,180,0';break;
case 12: col_B=C'0,190,255';col_R=C'255,190,0';break;
case 13: col_B=C'0,200,255';col_R=C'255,200,0';break;
case 14: col_B=C'0,205,255';col_R=C'255,205,0';break;
case 15: col_B=C'0,210,255';col_R=C'255,210,0';break;
case 16: col_B=C'0,215,255';col_R=C'255,215,0';break;
case 17: col_B=C'0,220,255';col_R=C'255,220,0';break;
case 18: col_B=C'0,235,255';col_R=C'255,235,0';break;
case 19: col_B=C'0,255,255';col_R=C'255,255,0';break;
}
if(flag==1)col=col_B;
else
{
if(flag==(-1)) col=col_R;
else
{
col=tab_color;
}
}
return(col);
}
//=========== ïåðèîä ==================================================
int f_Timeframe(string period)
{
int TF;
if(period=="M1")TF=1;
else
{
if(period=="M5")TF=5;
else
{
if(period=="M15")TF=15;
else
{
if(period=="M30")TF=30;
else
{
if(period=="H1")TF=60;
else
{
if(period=="M4")TF=240;
else
{
if(period=="D1")TF=1440;
else
{
if(period=="W1")TF=10080;
else
{
if(period=="MN")TF=43200;
else
{
if(period=="0")TF=0;
else
{
Alert("Îøèáêà óñòàíîâêè ïåðèîäà: "+period);
}
}
}
}
}
}
}
}
}
}
return(TF);
}
//========================================================================
Comments