Author: Copyright � 2007, HexSys vs Xupypr
ShowNews

This script is designed to enhance your trading experience by providing a visual and textual roadmap of upcoming economic news events directly on your trading charts. Instead of forcing you to check external calendars constantly, it automatically pulls data from an external file and plots it onto your workspace.

Core Functionality

The logic operates through three main processes: data synchronization, automated chart plotting, and real-time notifications.

1. Dynamic Time Synchronization The tool is built to recognize the difference between various time zones. It takes a global time input (GMT) and automatically converts it into your local trading time. This ensures that the news events you see on your screen match the current clock of your specific region, preventing any confusion regarding when an event is set to occur.

2. Automated Chart Visualization The script scans an external data file containing global news information. For every significant economic event found in that file:

  • Vertical Markers: It places a dashed vertical line on your chart at the exact moment the news is scheduled to break. This allows you to see "walls" of volatility ahead of time.
  • Color Coding: The script distinguishes between different types of impact. High-importance events are highlighted in a distinct color (Yellow), while standard news events are displayed in a more subtle tone (Silver).
  • Country Labeling: Each vertical line is automatically labeled with the country of origin, allowing you to identify at a glance which central bank or economy is about to release data.

3. On-Screen News Feed Beyond just drawing lines, the script compiles all the relevant news into a readable summary. If enabled, it creates a "News Feed" in the corner of your trading screen. This text area lists the time, country, and a brief description of the news headlines, giving you a comprehensive overview of the market's narrative without needing to leave your platform.

Practical Benefits for the User

  • Preparation: By visualizing news events as physical lines on the chart, you can better anticipate periods of high volatility and adjust your trading strategy accordingly.
  • Organization: It automatically cleans up old data, ensuring that only relevant, upcoming events are displayed, which keeps your charts clean and readable.
  • Efficiency: It removes the manual work of calculating time zone offsets and manually plotting news markers, allowing you to focus entirely on market analysis.
Miscellaneous
Uses files from the file systemIt reads information from a file
13 Views
0 Downloads
0 Favorites
ShowNews
//+------------------------------------------------------------------+
//|                                                     ShowNews.mq4 |
//|                                         Copyright © 2007, HexSys |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, HexSys vs Xupypr"
#property show_inputs

extern int   gmtTime     = 3; //ïî Ìîñêâå (GMT+03:00)
extern color cLine       = Silver;
extern color cLineI      = Yellow;
extern bool  ShowComment = true;

int start()
{
 int handle;
 color cnews;
 datetime some_time, cur_time=TimeLocal()-432000; //óäàëÿòü ëèíèè íåäåëüíîé äàâíîñòè (5 äíåé)
 string local_time, str, aNewsTime, aNewsImp, aNewsCountry, aNewsText, tempStr="\n";
   
 while (cur_time<TimeLocal())
 {
  str=StringConcatenate("Íîâîñòè ",TimeToStr(cur_time,TIME_DATE|TIME_MINUTES));
  if (ObjectFind(str)!=-1) ObjectDelete(str);
  cur_time+=60;
 }
 handle=FileOpen("news.csv",FILE_CSV|FILE_READ,";");
 if (handle>0)
 {
  while(true)
  {
   aNewsTime=FileReadString(handle);
   if (FileIsEnding(handle)) break;
   aNewsImp=FileReadString(handle);
   aNewsCountry=FileReadString(handle);
   aNewsText=FileReadString(handle);
   while(!FileIsLineEnding(handle))
   {
    str=FileReadString(handle);
    aNewsText=StringConcatenate(aNewsText," ",str);
   }
   some_time=StrToTime(aNewsTime);
   local_time=TimeToStr(some_time+3600*(gmtTime-3),TIME_DATE|TIME_MINUTES);
   some_time=some_time-7200;
   if (aNewsImp=="-") cnews=cLine; else cnews=cLineI;
   CreateObjects("Íîâîñòè "+local_time,cnews,some_time,aNewsCountry);
   tempStr=StringConcatenate(tempStr,local_time," ",aNewsCountry," ",aNewsText,"\n");
  }
  FileClose(handle);
  if (ShowComment) Comment(tempStr);
 }
 return(0);
}

void CreateObjects(string nm, color cl, datetime dt, string country) 
{
 string des;
 
 if (ObjectFind(nm)==-1)
 {
  ObjectCreate(nm,OBJ_VLINE,0,0,0);
  ObjectSet(nm,OBJPROP_COLOR,cl);
  ObjectSetText(nm,country);
 }
 else
 {
  if (ObjectGet(nm,OBJPROP_COLOR)!=cLineI) ObjectSet(nm,OBJPROP_COLOR,cl);
  des=ObjectDescription(nm);
  if (StringFind(des,country)==-1) ObjectSetText(nm,StringConcatenate(des,", ",country));
 } 
 ObjectSet(nm,OBJPROP_TIME1,dt);
 ObjectSet(nm,OBJPROP_WIDTH,0);
 ObjectSet(nm,OBJPROP_BACK,True);
 ObjectSet(nm,OBJPROP_STYLE,STYLE_DASH);
 ObjectSet(nm,OBJPROP_TIMEFRAMES,0x001F);
}

Comments