/* Change Symbol ya incluye su propio codigo, este archivo no esta incluido alli */ #define ONE_MINUTE 60 #define ONE_HOUR 3600 #define ONE_DAY 86400 #define ONE_WEEK 604800 #define TIME_TO_FILENAME(time) "News\\" + TimeToString(time, TIME_DATE) + ".txt" #define START_OF_CANDLE(time) time - time%ONE_DAY union LongDouble { long long_value; double double_value; }; enum NewsIndicatorMode { FILTER_IMPACT, //Filter by Impact FILTER_NEWS //Filter by News Name }; string months[]={ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; void ImportNewsFromPeriod(datetime initTime, datetime lastTime, bool rewrite_files = false) { if (MQLInfoInteger(MQL_TESTER)) return; MqlDateTime timeStruct; TimeToStruct(initTime, timeStruct); TransformDayToWeekInit(timeStruct); datetime currentTime = StructToTime(timeStruct); if (initTime >= lastTime) { ImportWeekNews(initTime, rewrite_files); } else { while(currentTime < lastTime && !IsStopped()) { currentTime = ImportWeekNews(currentTime, rewrite_files); if (currentTime == 0) return; currentTime += ONE_WEEK; } currentTime -= ONE_WEEK; } } datetime ImportWeekNews(datetime fromTime, bool rewrite_files = false) { if (MQLInfoInteger(MQL_TESTER)) return fromTime; //string cookie="fftimezone=Eet"; string cookie="fftimezone=Europe/Riga"; string headers; //string reqheaders="User-Agent: Mozilla/4.0\r\n"; char post[],result[]; int res; string domain = "http://www.forexfactory.com"; MqlDateTime timeStruct; TimeToStruct(fromTime, timeStruct); string currentWeek = GetCurrentWeek(timeStruct, fromTime); string subdomain="/calendar?week="+currentWeek; string url = domain + subdomain; int timeout=5000; ResetLastError(); string filename = TIME_TO_FILENAME(fromTime); if (FileIsExist(filename, FILE_COMMON) && !rewrite_files) { Print(filename, " found. Not reimported"); return fromTime; } else { Print("Importing week " + TimeToString(fromTime, TIME_DATE)); } res = WebRequest("GET", url, cookie, NULL, timeout, post, 0, result, headers); if(res==-1) { Print("Error in WebRequest. Error code =",GetLastError()); MessageBox("Add the address '"+domain+"' in the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION); return 0; } else { string resultStr = CharArrayToString(result,0,WHOLE_ARRAY,CP_UTF8); int i = StringFind(resultStr, "calendar__table", 0); i = StringFind(resultStr, "", i); int j = StringFind(resultStr, "