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);
}



Sample





Analysis



Market Information Used:



Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features:

Uses files from the file system
It reads information from a file