Download MetaTrader 5
To add comments, please log in or register
Sign up for MQL5.community to leave your comments!
MetaQuotes Software Corp.
Moderator
177113
MetaQuotes Software Corp. 2007.11.23 16:08 

New article Displaying a News Calendar has been published:

This article contains the description of writing a simple and convenient indicator displaying in a working area the main economic events from external Internet resources. The indicator's operation looks like this:



Here is a list of requirements for the indicator:
  • The indicator should independently (without a user's help) download a necessary file of the events calendar for the current week.
  • The indicator should display all events (both passed and future) from this file in the form of vertical lines with news headlines.
  • The indicator should trace the events' update on the external resource.
After we have specified the task, we can analyze some technical details.

Author: Slobodov Gleb

MQL4 Comments
16309
MQL4 Comments 2008.03.06 18:24  
With all files placed into the specified folders, error message "Time.mqh - cannot open program file" is generated while compiling the "CalendarArticle.mq4" file.  Any suggestions on how to fix this?
MQL4 Comments
16309
MQL4 Comments 2008.05.14 18:08  

Hi i can see the news on my trading station  but the news really pile up. Is there anyway to avoid this?

alex dahmen
19
alex dahmen 2008.05.24 14:36  
does it work ??????ß
MQL4 Comments
16309
MQL4 Comments 2008.06.20 17:00  

First I want to thank the author for taking his time to do this article. It saves a lot of my time trying to figure it out. However, when I run this, I notice the events fall on the wrong time once I checked some of them. Anyone has that issue and know how to fix it? Thanks!

c0d3
781
c0d3 2008.09.26 04:03  
This is a great indicator, i modified it to become an EA, and now, it waits for the news to come out then it trades it. When the actual news data is released, the EA compares the actual data either to the forecast data or the previous data, calculates percent change, then enters the trade. Also, the EA trades every country that is supported on Dailyfx.com. Thx, for creating this awesome indicator and this awesome article.
c0d3
781
c0d3 2008.10.02 00:44  

I found an error in the algorithm that determined an integer in seconds since "Jan 1, 1970". When there is a "PM" in news-time(stTime), the function assumes that the time starts from zero (0). So in this fashion, when the news-time is "12:30 PM", it is actually "0:30 PM". So when the algorithm gets to "12:30 PM", it thinks that the news-time(stTime) is 12 hours ahead, which gives errors in displaying events, and trading decisions. In my EA, this issue caused the EA to wait for 12hours before going to the next event, therefore, i wrote code to fix this, if you are interested, the modification is below.

Replace the following:

if (StringFind(stTime,"PM")>=0)
Res+=12*60*60;
Res=Res-GetShiftGMT();

With the following:

if (StringFind(stTime,"PM")>=0)
Res+=12*60*60;
Res=Res-GetShiftGMT();
if((StringFind(stTime,"12"))>=0 && (StringFind(stTime,"PM"))>=0){Res=Res-(TimeHour(Tm )*60*60)-(TimeMinute(Tm )*60);}

MQL4 Comments
16309
MQL4 Comments 2008.10.21 18:28  

//+------------------------------------------------------------------+
//| dll.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern string HtmlAdress = "http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv";
extern string GetrightAdress = "c:\progra~1\getright\getright.exe";

#include <Time.mqh>
#import "kernel32.dll"
int WinExec(string NameEx, int dwFlags);

void DownloadCalendar()
{
Print("Downloading "+HtmlAdress+" to experts\files\html\Calendar.csv");
WinExec(GetrightAdress+" /URL:"+HtmlAdress+" /FILE:Calendar.csv /W /O",0);
}

datetime PerviousMonday(datetime d)
{
datetime res = d - (TimeDayOfWeek(d)-1)*24*60*60;
return(res);
}
datetime ToDate(string stDate,string stTime)
{
string WeekDay = StringSubstr(stDate,0,3);
int WeekPlus = 0;
if (WeekDay=="Mon") WeekPlus=0;
if (WeekDay=="Tue") WeekPlus=1;
if (WeekDay=="Wed") WeekPlus=2;
if (WeekDay=="Thu") WeekPlus=3;
if (WeekDay=="Fri") WeekPlus=4;
if (WeekDay=="Sat") WeekPlus=5;
if (WeekDay=="Sun") WeekPlus=-1;
datetime Res = PerviousMonday(GetTimeGMT())+WeekPlus*24*60*60;
datetime Tm = StrToTime(stTime);
Res=Res+TimeHour(Tm )*60*60+TimeMinute(Tm )*60+TimeSeconds(Tm )
-TimeHour(Res)*60*60-TimeMinute(Res)*60-TimeSeconds(Res);

if (StringFind(stTime,"PM")>=0)
Res+=12*60*60;
Res=Res-GetShiftGMT();
if((StringFind(stTime,"12"))>=0 && (StringFind(stTime,"PM"))>=0){Res=Res-(TimeHour(Tm )*60*60)-(TimeMinute(Tm )*60);}

return (Res);
}

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);
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++;
}
Max = i;
if (file!=-1)
FileClose(file);
}

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if (TimeCurrent()>LastTimeDownloading+15*60)
{
DeleteObjects();
DownloadCalendar();
LastTimeDownloading = TimeCurrent();

int file=-1;
while (file==-1)
file = FileOpen("\Html\Calendar.csv",FILE_READ|FILE_CSV,',');
FileClose(file);

GrabNews();
}

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

i have a error here pls help ...

'Max' - variable not defined D:\alpari-idc\experts\indicators\dll.mq4 (88, 2)
'LastTimeDownloading' - variable not defined D:\alpari-idc\experts\indicators\dll.mq4 (119, 22)
'LastTimeDownloading' - variable not defined D:\alpari-idc\experts\indicators\dll.mq4 (123, 8)

or can u just add the indicator for me ?? plss cause i m new in mql 4 or can you add a template

jhp 2025
20
jhp 2025 2008.11.25 07:17  
how if we don't use getright? can we?
MQL4 Comments
16309
MQL4 Comments 2008.12.01 01:27  

Hello,

Thank you for the good article.

I just want to make a note that kernel32.dll is spelled incorrectly right at the end of the article. The spelling in the article is kernell32.dll. The dll is spelled correctly in the files for downloading.

MQL4 Comments
16309
MQL4 Comments 2009.02.20 18:49  
I mean the Auto optimization. Where will it be? I love to use the EA and see positive result.
/ /123
To add comments, please log in or register