Displaying a News Calendar - Suggestion

 

Hi,

In "Displaying a News Calendar" code (Author: Slobodov Gleb), I have a suggestion.

Add new lines (highlighted with "<<---- new line" below) in GrabNews() function, and news calendar display only that currency.

Example: If EURUSD, display only news about EUR or USD.

void GrabNews() 
{
  int file = FileOpen("\Html\Calendar.csv",FILE_READ|FILE_CSV,',');
  if (file==-1||FileSize(file)==0)
        return;
   
  int i=0;
  while (!FileIsEnding(file))
    {
      string stDate="";
      while (!FileIsEnding(file)&&stDate=="")
        stDate = FileReadString(file);
        
      string stTime = FileReadString(file);
      string stTimeZone = FileReadString(file);
      string stCurrency = FileReadString(file);
      string stDescription = FileReadString(file);
      string stImportance = FileReadString(file);
      string stActual = FileReadString(file);
      string stForecast = FileReadString(file);
      string stPrevious = FileReadString(file);
      
      string cur1 = StringSubstr(Symbol(),0,3); // <<---- new line
      string cur2 = StringSubstr(Symbol(),3,5); // <<---- new line
      
      if(cur1 == stCurrency || cur2 == stCurrency){ // <<---- new line
      
      datetime Date = ToDate(stDate,stTime);
      
      color c=Green;
      if (stImportance=="Low") c = Yellow;
      if (stImportance=="Medium") c = Orange;
      if (stImportance=="High") c = Red;
         
      ObjectCreate("CalendarText"+i, OBJ_TEXT, 0, Date, Close[0]);
      ObjectSet("CalendarText"+i, OBJPROP_COLOR, c);          
      ObjectSetText("CalendarText"+i, stDate + " : "+ stDescription, 8);          
      ObjectSet("CalendarText"+i, OBJPROP_ANGLE, 90);          
                   
      ObjectCreate("CalendarLine"+i, OBJ_VLINE, 0, Date, Close[0]);
      ObjectSet("CalendarLine"+i, OBJPROP_COLOR, c);                    
      ObjectSet("CalendarLine"+i, OBJPROP_STYLE, STYLE_DOT);                    
      ObjectSet("CalendarLine"+i, OBJPROP_BACK, true);          
      ObjectSetText("CalendarLine"+i, stDescription, 8);                    
      
      i++;
      } // <<---- new line
      
    }
  Max = i;
  if (file!=-1)
    FileClose(file);
    
}

Thanks,

EMEBroker