InterestLines

Download script
Author: Abhi
InterestLines

This script is designed to enhance your trading charts by automatically importing and visualizing important economic data from an external data file. Instead of you having to manually mark dates for significant financial events, the tool handles the heavy lifting of identifying these milestones and placing them directly on your screen.

How it Works

The logic follows a straightforward three-step process to ensure your chart stays updated with relevant information:

1. Data Retrieval The script looks for a specific text file (configured by default as "USAinterest.txt") stored within the platform's data folder. It opens this file and reads through its contents line by line. Each entry in this file typically contains several pieces of information, such as the date, time, a description of the event (like interest rate changes), the country involved, the specific period, the current value, and the forecasted value.

2. Automated Plotting As the script reads each piece of data from the file, it performs the following actions:

  • Vertical Lines: It places a dotted vertical line on your chart at the exact date and time specified in the file. This provides a clear visual "boundary" or marker for when an economic event occurred or is scheduled to occur.
  • Informational Labels: If the display setting is enabled, the script creates text labels associated with these lines. These labels aggregate all the data from the file—description, country, period, current figures, and forecasts—and display them clearly on the chart.

3. Visual Organization The tool is designed to stay organized by automatically naming every new line and text label it creates. By placing these markers in the background of your chart, it allows you to see the historical context of economic shifts without cluttering the primary price action. The labels are oriented vertically or positioned strategically so that they provide necessary information at a glance without obstructing your view of the market's movement.

Key Benefits

  • Contextual Awareness: You can immediately see where major economic announcements fall in relation to price history.
  • Efficiency: It eliminates the need to manually draw lines and type out notes for every economic release.
  • Comprehensive Data: By pulling from a file, the script ensures that you aren't just seeing a "marker," but also the specific details (like forecasts vs. actuals) provided in your data source.
Miscellaneous
Uses files from the file systemIt reads information from a file
12 Views
0 Downloads
0 Favorites
InterestLines
//+------------------------------------------------------------------+
//|                                                InterestLines.mq4 |
//|                                           Copyright © 2006, Abhi |
//|                                http://www.megadelfi.com/experts/ |
//|                            E-mail: interestlines{Q)megadelfi.com |
//|                       fix my e-mail address before mailing me ;) |
//+------------------------------------------------------------------+
#property copyright "Abhi"
#property link      ""
#property show_inputs
#property indicator_chart_window

extern bool DisplayText = true;


extern color UpColor = Red;
extern color DownColor = Blue;

extern string FileName = "USAinterest.txt";



int start()
  {
  
//  ObjectsDeleteAll();
  
   int handle;
   handle=FileOpen(FileName,FILE_CSV|FILE_READ,';');
   if(handle<1)
    {
     Print("File not found, the last error is ", GetLastError());
     return(false);
    }
    
    
   int i= 0;
   while(!FileIsEnding(handle))
   {
    string sDate=FileReadString(handle); // Date
    string sTime=FileReadString(handle); // Time
    string sDescription=FileReadString(handle); // Description
    string sCountry=FileReadString(handle); // Country
    string sPeriod=FileReadString(handle); // Period
    string sCurrent=FileReadString(handle); // Current value
    string sForecast=FileReadString(handle); // Expected
    FileReadString(handle); // null
    
    i++;
    datetime dt = StrToTime(sDate+" "+sTime);
    
         color c = Orange;
            
          if (DisplayText)
          {
          ObjectCreate(FileName+"_text"+i, OBJ_TEXT, 0, dt, Close[0]-0.1);
          ObjectSet(FileName+"_text"+i, OBJPROP_COLOR, c);          
          ObjectSetText(FileName+"_text"+i, sDescription + " "+ sCountry + " " + sPeriod + " " + sCurrent + " " + sForecast, 9);          
          ObjectSet(FileName+"_text"+i, OBJPROP_ANGLE, 90);          
          }
          
                   
          ObjectCreate(FileName+"_line"+i, OBJ_VLINE, 0, dt, Close[0]);
          ObjectSet(FileName+"_line"+i, OBJPROP_COLOR, c);                    
          ObjectSet(FileName+"_line"+i, OBJPROP_STYLE, STYLE_DOT);                    
          ObjectSet(FileName+"_line"+i, OBJPROP_BACK, true);          
          ObjectSetText(FileName+"_line"+i, sDescription + " "+ sCountry + " " + sPeriod + " " + sCurrent + " " + sForecast, 8);                    

   }    

   return(0);
  }
//+------------------------------------------------------------------+

Comments