Download MetaTrader 5

How to program in the MetaEditor to respond to a website using PHP?

To add comments, please log in or register
AaronEstrada
8
AaronEstrada  
I've been doing some extensive research these past few days from figuring out how to get mql4 to POST data to a website where PHP will pick up the POST. I've read forums to use webrequest(), but no luck. Thank you in advance!
Fernando Carreiro
3867
Fernando Carreiro  
AaronEstrada: I've been doing some extensive research these past few days from figuring out how to get mql4 to POST data to a website where PHP will pick up the POST. I've read forums to use webrequest(), but no luck. Thank you in advance!

Luck has nothing to do with it. It requires good coding skills in MQL and PHP and extensive knowledge with regards to the HTTP protocol.

In fact, the use of the WebRequest() function in MQL is the easiest part. The rest, especially the knowledge about the HTTP protocol,  is where you will need to focus the most of your effort and research in order to obtain the necessary knowledge and skills.

Forum on trading, automated trading systems and testing trading strategies

Metatrader 4 to Binary.com

Fernando Carreiro, 2016.09.14 10:04

You must first set permissions on MetaTrader's Options in order to allow access to that website. Go to the "Tools->Options" (or Ctrl+O) and then go to the "Expert Advisors" tab. At the very end of those options, to will find and have to enable the "Allow WebRequest for the listed URL:" and then proceed to add the URL of the site.

NB! Also, depending on the data being retrieved, you may need to use the 2nd version of WebRequest as the first one is only valid for form data (Content-Type: application/x-www-form-urlencoded).

Forum on trading, automated trading systems and testing trading strategies

Auto trading the news

Fernando Carreiro, 2016.09.02 00:18

You will have to collect that data from Websites that are offering those services (be they paid or free). You can use the function WebRequest() to obtain data from the web, but you will have to learn about HTTP, and depending on the API the website provides, you may also need to learn REST,  JSON or XML or even standard HTML. These web protocols are however beyond the scope of this forum, so for more information you will have to search the Internet. Here are some links to get you started:

Please note, that collecting and parsing Web data via an API, is not something for a beginner or newbie coder. It requires at least an intermediate level of coding knowledge and good understanding about web protocols.

I also suggest reading the following threads on here:

EDIT: There are also relevant entries in the Codebase that will be of interest to you (had you done a search):

NB! However, please note that WebRequest() only works in EA's and Scripts but not in Indicators.

WebRequest - Common Functions - MQL4 Reference
WebRequest - Common Functions - MQL4 Reference
  • docs.mql4.com
To use the WebRequest() function, add the addresses of the required servers in the list of allowed URLs in the "Expert Advisors" tab of the "Options" window. Server port is automatically selected on the basis of the specified protocol - 80 for "http://" and 443 for "https://". The WebRequest() function is synchronous, which means its breaks the...
Stanislav Korotky
23152
Stanislav Korotky  
AaronEstrada:
I've been doing some extensive research these past few days from figuring out how to get mql4 to POST data to a website where PHP will pick up the POST. I've read forums to use webrequest(), but no luck. Thank you in advance!

Try to adopt this example (comments in Russian, use autotranslation feature).

To add comments, please log in or register