|
|
@@ -468,43 +468,52 @@ void fillNewsStruct()
|
|
468
|
468
|
//+------------------------------------------------------------------+
|
|
469
|
469
|
void updateNews()
|
|
470
|
470
|
{
|
|
471
|
|
- string cookie=NULL,strNews;
|
|
472
|
|
- string reqheaders="User-Agent: Mozilla/4.0\r\n";
|
|
473
|
|
- char post[],result[];
|
|
474
|
|
- int res;
|
|
475
|
|
-//http://www.forexfactory.com/ffcal_week_this.xml
|
|
476
|
|
- string url="https://cdn-nfs.faireconomy.media/ff_calendar_thisweek.xml";
|
|
477
|
|
- url="https://nfs.faireconomy.media/ff_calendar_thisweek.xml";
|
|
478
|
|
- ResetLastError();
|
|
479
|
|
- int timeout=5000;
|
|
480
|
|
-//res=WebRequest("GET",url,reqheaders,timeout,post,result,headers);
|
|
481
|
|
- res=InternetGetFile(url,strNews);
|
|
482
|
|
-
|
|
483
|
|
- StringToCharArray(strNews,result);
|
|
484
|
|
- if(res==-1)
|
|
|
471
|
+ datetime lastFileModified=(datetime)FileGetInteger(fileName,FILE_MODIFY_DATE);
|
|
|
472
|
+ if(lastFileModified < iTime(Symbol(), PERIOD_D1, 0))
|
|
485
|
473
|
{
|
|
486
|
|
- Print("Error in WebRequest. Error code =",GetLastError());
|
|
487
|
|
- //--- Perhaps the URL is not listed, display a message about the necessity to add the address
|
|
488
|
|
- MessageBox("Add the address '"+url+"' in the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
|
|
489
|
|
- }
|
|
490
|
|
- else
|
|
491
|
|
- {
|
|
492
|
|
- //--- Load successfully
|
|
493
|
|
- PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
|
|
494
|
|
- //--- Save the data to a file
|
|
495
|
|
- int filehandle=FileOpen(fileName,FILE_WRITE|FILE_BIN);
|
|
496
|
|
- //--- Checking errors
|
|
497
|
|
- if(filehandle!=INVALID_HANDLE)
|
|
|
474
|
+ Print(" ---------------------------------------- Updating News File ------------------------------------- ");
|
|
|
475
|
+ string cookie=NULL,strNews;
|
|
|
476
|
+ string reqheaders="User-Agent: Mozilla/4.0\r\n";
|
|
|
477
|
+ char post[]
|
|
|
478
|
+ ,result[];
|
|
|
479
|
+ int res;
|
|
|
480
|
+ //http://www.forexfactory.com/ffcal_week_this.xml
|
|
|
481
|
+ string url="https://cdn-nfs.faireconomy.media/ff_calendar_thisweek.xml";
|
|
|
482
|
+ url="https://nfs.faireconomy.media/ff_calendar_thisweek.xml";
|
|
|
483
|
+ ResetLastError();
|
|
|
484
|
+ int timeout=5000;
|
|
|
485
|
+ //res=WebRequest("GET",url,reqheaders,timeout,post,result,headers);
|
|
|
486
|
+ res=InternetGetFile(url,strNews);
|
|
|
487
|
+
|
|
|
488
|
+ StringToCharArray(strNews,result);
|
|
|
489
|
+ if(res==-1)
|
|
498
|
490
|
{
|
|
499
|
|
- //--- Save the contents of the result[] array to a file
|
|
500
|
|
- FileWriteArray(filehandle,result,0,ArraySize(result));
|
|
501
|
|
- //--- Close the file
|
|
502
|
|
- FileClose(filehandle);
|
|
|
491
|
+ Print("Error in WebRequest. Error code =",GetLastError());
|
|
|
492
|
+ //--- Perhaps the URL is not listed, display a message about the necessity to add the address
|
|
|
493
|
+ MessageBox("Add the address '"+url+"' in the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
|
|
503
|
494
|
}
|
|
504
|
495
|
else
|
|
505
|
|
- Print("Error in FileOpen. Error code=",GetLastError());
|
|
|
496
|
+ {
|
|
|
497
|
+ //--- Load successfully
|
|
|
498
|
+ PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
|
|
|
499
|
+ //--- Save the data to a file
|
|
|
500
|
+ int filehandle=FileOpen(fileName,FILE_WRITE|FILE_BIN);
|
|
|
501
|
+ //--- Checking errors
|
|
|
502
|
+ if(filehandle!=INVALID_HANDLE)
|
|
|
503
|
+ {
|
|
|
504
|
+ //--- Save the contents of the result[] array to a file
|
|
|
505
|
+ FileWriteArray(filehandle,result,0,ArraySize(result));
|
|
|
506
|
+ //--- Close the file
|
|
|
507
|
+ FileClose(filehandle);
|
|
|
508
|
+ }
|
|
|
509
|
+ else
|
|
|
510
|
+ Print("Error in FileOpen. Error code=",GetLastError());
|
|
|
511
|
+ }
|
|
|
512
|
+ }
|
|
|
513
|
+ else
|
|
|
514
|
+ {
|
|
|
515
|
+ Print(" ---------------------------------------- News File Already Updated ------------------------------------- ");
|
|
506
|
516
|
}
|
|
507
|
|
-
|
|
508
|
517
|
}
|
|
509
|
518
|
//+------------------------------------------------------------------+
|
|
510
|
519
|
//| |
|