try this :
(place in experts folder) and the mqh file in Include folder
#property copyright "Forum.Thread" #property link "https://www.mql5.com/en/forum/351725" #property version "1.00" #property description "Telegram : https://t.me/lorentzor\nInstagram : @rlorentzo\nTwitter : @lorentzo_r\nLinkedIn : https://www.linkedin.com/in/lorentzor\nYoutube : https://www.youtube.com/channel/UCM0Lj06cAJagFWvSpb9N5zA\nFacebook : @LorentzoR" /* ways to connect .> : Telegram : https://t.me/lorentzor Instagram : https://www.instagram.com/rlorentzo /OR/ @rlorentzo Twitter : https://twitter.com/lorentzo_r /OR/ @lorentzo_r LinkedIn : https://www.linkedin.com/in/lorentzor Youtube : https://www.youtube.com/channel/UCM0Lj06cAJagFWvSpb9N5zA Facebook : https://www.facebook.com/LorentzoR /OR/ @LorentzoR Mql5.com : https://www.mql5.com/en/users/lorio */ #property strict #include <LorioTools\WebRequests.mqh> input string baseUrl="https://mql4.requestcatcher.com/";//Base URL : (the request will go there) input wr_type requestType=wr_type_get;//Post Request : input uint requestTimeout=3000;//Request timeout milliseconds : input string referer="https://www.mql5.com/en/forum/351725";//Referer enum uau{ ua_none=0,//None ua_custom=1,//Custom (enter below) ua_mozilla=2//Mozilla }; input uau UserAgentUsed=ua_custom;//User Agent Used : string Mozilla="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0"; input string UserAgent="MT4/v1310 GR";//User Agent : input string param1Name="Param1";//Param 1 Name input string param1Data="Data1";//Param 1 Data input string param2Name="Param2";//Param 2 Name input string param2Data="Data2";//Param 2 Data input string param3Name="Param3";//Param3 Name input string param3Data="Data3";//Param3 Data web_request WR; int OnInit() { WR.SetupWithBasicHeaders(requestType,baseUrl,requestTimeout); if(referer!=""){WR.SetReferer(referer);} if(UserAgentUsed==ua_mozilla){WR.SetUserAgent(Mozilla);} if(UserAgentUsed==ua_custom){WR.SetUserAgent(UserAgent);} //parameters if(param1Name!=""){WR.Parameters+param1Name=param1Data;} /* or if(param1Name!=""){WR.Parameters[param1Name]=param1Data;} */ if(param2Name!=""){WR.Parameters+param2Name=param2Data;} if(param3Name!=""){WR.Parameters+param3Name=param3Data;} //WR.Cookies+"CookieLast"=TimeToString(TimeLocal(),TIME_DATE|TIME_MINUTES|TIME_SECONDS); simple_result result=WR.Send(); Print("Errors : "+result.error); if(result.status==200) { Alert("response headers : \n"+result.response_headers+"\nresponse body : \n"+result.response_body); } return(INIT_SUCCEEDED); } void OnDeinit(const int reason){} void OnTick(){}
Files:
Masoud1365:
Thank you for your reply.
is it for mql4 ?
i want to receive data in my EA, for exapmle power of USD or Corellation of EURUSD.
my question is how can receive data via json or any way.
thanks
it works on both platforms.
To do what you want , you will need to find a provider of the data you want.
and then code the json (or use a json library) to read the data this request returns
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hi dear,
can i send and receive data in ea in mql4 using webrequest ? (send and receive via json or ... ?)
thanks