WebRequest cookies problem ... I think

 

Hi,

I am trying to retrieve the calendar from the investing website to show on MT5.

void test()
{
   string cookie=NULL,headers;
   char post[],result[];
   int res;
   int timeout=5000;
   string url="https://sslecal2.investing.com/?columns=exc_currency,exc_importance&importance=3&countries=72,17,4,5&calType=day&timeZone=58&lang=1";

   ResetLastError();

   res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers);

}

I have this URL that in a browser works OK, but if I load it through WebRequest in MQL5 it gives me a permission denied error like this



It seems that the error is a permission denied because I am not sending cookies, but I don't know how to do it.


Could you help me?


Thank you !!

 
israelhernando:

Hi,

I am trying to retrieve the calendar from the investing website to show on MT5.

I have this URL that in a browser works OK, but if I load it through WebRequest in MQL5 it gives me a permission denied error like this



It seems that the error is a permission denied because I am not sending cookies, but I don't know how to do it.


Could you help me?


Thank you !!

Can't help you in that particular cookie-question, because this seems to be not solvable by just returning a cookie sent by this particular webpage. In short: The URL you called doesn't send a cookie it self, but a return of an afterwards requested Javascript. The Browser does this automatically, but you'd have to interpret the HTML, load, interpret & run the JS, etc. And even if this would be possible easily, if they change their page, your program wouldn't work anymore.

So why don't you use the calendar integrated in MT5? See: https://www.mql5.com/en/docs/calendar


Edit: Just added an screenshot as a proof, that your URL itself doesn't send a cookie.

Documentation on MQL5: Economic Calendar
Documentation on MQL5: Economic Calendar
  • www.mql5.com
Economic Calendar - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
 
Thomas S. #:

Can't help you in that particular cookie-question, because this seems to be not solvable by just returning a cookie sent by this particular webpage. In short: The URL you called doesn't send a cookie it self, but a return of an afterwards requested Javascript. The Browser does this automatically, but you'd have to interpret the HTML, load, interpret & run the JS, etc. And even if this would be possible easily, if they change their page, your program wouldn't work anymore.

So why don't you use the calendar integrated in MT5? See: https://www.mql5.com/en/docs/calendar


Edit: Just added an screenshot as a proof, that your URL itself doesn't send a cookie.


Thanks for answering,

I want to use the investing.com calendar because it is more complete, the mql one does not show all the events.

Thank you

 
israelhernando #:

Thanks for answering,

I want to use the investing.com calendar because it is more complete, the mql one does not show all the events.

Thank you

I you're missing some events in the MQL-calendar, i'd suggest to post a request here in the forum and write what exactly you're missing.

Because it doesn't make sense IMHO that everybody has to find his own external solution, if there is an integrated tool and just a view details are missing - help them getting better ;)

Reason: