Price Change
Download scriptThis tool is designed to provide traders with a real-time visual summary of the current price movement relative to the start of the trading day. Instead of forcing you to manually calculate the difference between the opening price and the current market rate, this script automates that calculation and displays it clearly directly on your trading chart.
How it Works
The logic follows a straightforward three-step process:
1. Automated Context Awareness The script first identifies which currency pair you are currently viewing. Because different currency pairs use different decimal scales (for example, Japanese Yen pairs typically have fewer decimal places than most other currencies), the tool automatically adjusts its internal math to ensure the displayed numbers are accurate and formatted correctly for that specific market.
2. Dynamic Price Comparison The script constantly monitors two key data points:
- The Daily Opening Price: It looks back to the very beginning of the current day's session.
- The Live Bid Price: It captures the most recent current price offered in the market.
By subtracting the opening price from the live price, the script determines the total "net change" for the day.
3. Visual Feedback System Once the calculation is complete, the tool renders a text label on your screen. To make this information easy to read at a glance, it uses a color-coded system to indicate market direction:
- Green: The price is currently higher than the opening price (Positive movement).
- Red: The price is currently lower than the opening price (Negative movement).
- Gold: The price is exactly equal to the opening price (Neutral movement).
Key User Benefits
- Real-Time Tracking: You can see exactly how much a pair has moved from the daily open without having to scroll back through historical candles.
- Customizable Display: You can adjust the font size, type, and the specific corner of your screen where the information appears to suit your personal layout.
- Clean Interface: The tool is designed to be unobtrusive, providing essential data in a clear, high-visibility format that integrates seamlessly with your existing charts.
//+------------------------------------------------------------------+
//| Price Change.mq4 |
//| cja. |
//+------------------------------------------------------------------+
#property indicator_chart_window
extern int Font_SIZE = 40;
extern string Font_TYPE = "Arial";
extern int BarsShift_Side = 0;
extern int BarsShift_UP_DN = 20;
extern int WindowToUse = 0;
extern int CornerToUse = 0;
int nDigits, Precision, nDigitsMINUS;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int CreateTEXT( string n, int BarsShift_UP_DN, int BarsShift_Side ) {
ObjectCreate( n, OBJ_LABEL, WindowToUse, 0, 0 );
ObjectSet( n, OBJPROP_CORNER, CornerToUse );
ObjectSet( n, OBJPROP_XDISTANCE,BarsShift_Side );
ObjectSet( n, OBJPROP_YDISTANCE,BarsShift_UP_DN);
ObjectSet( n, OBJPROP_BACK, false );
}
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("Price");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if( StringFind( Symbol(), "JPY", 0) != -1 )
{nDigitsMINUS = 0; Precision = 100; nDigits = 2;} else {nDigitsMINUS = 2; Precision = 10000; nDigits = 4; }
double today_open = iOpen(NULL,1440,0);
double ChangeVal = (Bid - today_open)*Precision;
string CHANGE = (DoubleToStr(ChangeVal,nDigits-nDigitsMINUS));
CreateTEXT( "Price",40+BarsShift_UP_DN,40+BarsShift_Side);
if (ChangeVal == 0)
{
ObjectSetText( "Price","+"+CHANGE+" ", Font_SIZE,Font_TYPE, Gold);
}
else if (ChangeVal > 0) {
ObjectSetText( "Price","+"+CHANGE+" ", Font_SIZE,Font_TYPE, Lime);
}
else {
ObjectSetText( "Price"," "+CHANGE+" ", Font_SIZE,Font_TYPE, Red);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments