Советники: News EA Template without DLL - страница 2

 
Спасибо, полезный код.
 
Огромнейшее спасибище!!!

Очень нужная вещь, давно искал.
 

В READCBOE в своей сове я добавил.

string NameFile=StringConcatenate(Symbol(),"-chart_news-log.html");

И‌ везде "news-log.html" заменил на NameFile. 

Я это сделал для того, чтобы не было FileOpen error, когда одновременно используются множество графиков. вместо Symbol() можно и ChartID.

//+------------------------------------------------------------------+
//////////////////////////////////////////////////////////////////////////////////
// Download CBOE page source code in a text variable
// And returns the result
//////////////////////////////////////////////////////////////////////////////////
string ReadCBOE()
  {

   string cookie=NULL,headers;
   char post[],result[];     string TXT="";
   string NameFile=StringConcatenate(Symbol(),"-chart_news-log.html");
   int res;
//--- to work with the server, you must add the URL "https://www.google.com/finance"  
//--- the list of allowed URL (Main menu-> Tools-> Settings tab "Advisors"):
   string google_url="http://ec.forexprostools.com/?columns=exc_currency,exc_importance&importance=1,2,3&calType=week&timeZone=15&lang=1";
//---
   ResetLastError();
//--- download html-pages
   int timeout=5000; //--- timeout less than 1,000 (1 sec.) is insufficient at a low speed of the Internet
   res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
//--- error checking
   if(res==-1)
     {
      Print("WebRequest error, err.code  =",GetLastError());
      MessageBox("You must add the address ' "+google_url+"' in the list of allowed URL tab 'Advisors' "," Error ",MB_ICONINFORMATION);
      //--- You must add the address ' "+ google url"' in the list of allowed URL tab 'Advisors' "," Error "
     }
   else
     {
      //--- successful download
      PrintFormat("File successfully downloaded, the file size in bytes  =%d.",ArraySize(result));
      //--- save the data in the file
      int filehandle=FileOpen(NameFile,FILE_WRITE|FILE_BIN);
      //--- проверка ошибки
      if(filehandle!=INVALID_HANDLE)
        {
         //---save the contents of the array result [] in file
         FileWriteArray(filehandle,result,0,ArraySize(result));
         //--- close file
         FileClose(filehandle);

         int filehandle2=FileOpen(NameFile,FILE_READ|FILE_BIN);
         TXT=FileReadString(filehandle2,ArraySize(result));
         FileClose(filehandle2);
        }
      else
        {
         Print("Error in FileOpen. Error code =",GetLastError());
        }
     }

   return(TXT);
  }
 
Спасибо большое!!!
 

Спасибо за идею!

Пару вопросов возникло. Просто интересно...

Зачем писать в файл, стразу из него читать и больше нигде его не использовать? Может я что-то недосмотрел?..

И зачем городить это

string time=StringConcatenate(StringSubstr(s,0,4),".",StringSubstr(s,5,2),".",StringSubstr(s,8,2)," ",StringSubstr(s,11,2),":",StringSubstr(s,14,4));
если есть StringReplace ?
 
Тестирую советник. Почему он отображает только сильные новости (красные линии) независимо от настроек?
 
Elena Baranova:
Тестирую советник. Почему он отображает только сильные новости (красные линии) независимо от настроек?

вы тестируете только тот кусок который выложен или его вписали уже в код своего советника ?

 
Elena Baranova:
Тестирую советник. Почему он отображает только сильные новости (красные линии) независимо от настроек?

   Перенесите часть кода

   Vhigh=NewsHard;   Vmedium=NewsMedium;   Vlow=NewsLight;

   из OnInit() в OnTick()

 
if(NomNews==300)break;

Вот это условие остановки цикла для чего?

 

что то не могу разобраться - окошко какое то, выскакивает. Может кто подскажет что, я делаю не так?

news 

с помощью этой утилиты https://www.mql5.com/ru/market/product/34125

для мт 5

------------ вот что пишет. это правда что новостей нет? no news

Файлы:
news.mq5  36 kb