metatrader4

How to read a JSON from a URL in MQL5?

依然范特西╮ 提交于 2019-12-03 21:54:12
How can I read JSON from a url in MQL5 ? For example this simple JSON from: https://api.myjson.com/bins/56z28 { "employees": [ { "firstName": "John", "lastName": "Doe" }, { "firstName": "Anna", "lastName": "Smith" }, { "firstName": "Peter", "lastName": "Jones" } ] } user3666197 Simple, but restrictions apply. MetaTrader Terminal 5 is a code-execution environment, that can communicate with an external URL target (if explicitly configured as a permitted URL) via both HTTP/HTTPS protocols over port 80/443 respectively. string aCookieHOLDER = NULL, aHttpHEADERs; char postBYTEs[], replBYTEs[]; int

How to return a string from a C++ DLL into a MetaTrader 4 code-execution ecosystem?

徘徊边缘 提交于 2019-12-03 21:37:27
I have following function __declspec(dllexport) wchar_t* __stdcall __getJson(wchar_t * listN){ setlocale(LC_ALL, ""); //function logic wstring ant = utf8_to_wstring(result); const WCHAR* constRes = ant.c_str(); WCHAR* tempObj=new WCHAR[ant.length()]; wcscpy(tempObj, constRes); thread Thread([tempObj]{ Sleep(1000); delete[] tempObj; }); Thread.detach(); return tempObj; } This DLL returns wchar_t* to MetaTrader4. I tried many ways to return correct value and avoid memory leaks such as set return type const wchar_t* , creating my own class with destructor with delete[] in. But all this attempts

How can I write mql4 code (EA) that marks the listed candle patterns with rectangles

混江龙づ霸主 提交于 2019-12-03 11:45:12
问题 I am quite new to writing mql4 code and would be grateful if I could get some help drawing rectangles when the following candlestick patterns occur: FIG1: Run code snippet <blockquote class="imgur-embed-pub" lang="en" data-id="a/fRoPzsm"><a href="//imgur.com/a/fRoPzsm">Demand Zone 1</a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script> FIG2: Run code snippet <blockquote class="imgur-embed-pub" lang="en" data-id="a/4E8KE1R" data-context="false"><a href="/

Writing an expert adviser in [ MQL4 ]

一曲冷凌霜 提交于 2019-12-01 09:18:30
问题 So if I wanted an EA in MQL4 that took the open price and when current price was 10 pips below the open it places a buy order and when it was 10 pips above the open it sold. Only one order at a time and the open changed daily. Q1: How could that run unstopped? Q2: Would that even be profitable? I know this is simple for some people to write but for me it's depressing. 回答1: A1: the simplest part ... The MQL4 Expert Advisor type-of-code's execution can be principally run unstopped, supposing

How to compile an MQL4 file with a command-line tool?

核能气质少年 提交于 2019-11-29 15:32:39
问题 Now I am compiling my MetaTrader .mq4 files to .ex4 files with MetaEditor . But my .mq4 files are generated by a Java-process, and I would like to automate the compilation process. Is there a command-line compiler tool I could call programmatically? 回答1: Yes, there is an executable in the install directory of the terminal. It is called metalang.exe. 回答2: To compile a source code file from a command line, you can use MetaEditor for that. For example: metaeditor.exe /compile:"C:\Program Files

Asynchronous web requests for MetaTrader [closed]

陌路散爱 提交于 2019-11-29 00:05:19
I am trying to see whether it is feasible to build a custom indicator for MetaTrader that can make asynchronous internet requests, in order to post data to a server with a PHP interface. These requests might take some time for the webserver to process, so I am worried that they will block the indicator from continuously updating new tick data if they are performed in a synchronous manner. Are there any asynchronous libraries available for MT4? Yes, there are MT4 can directly use ready-made bindings for great platform-to-platform & process-to-process messaging library, be it ZeroMQ or nanomsg .

Evaluation requires a thread to run temporarily. Use the Watch window to perform the evaluation

流过昼夜 提交于 2019-11-28 12:03:14
I'm completely stuck . I'm testing MetaTrader API and getting next error when tries to run a method in the Immediate Window of VS 2010: A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll A first chance exception of type 'System.Threading.ThreadAbortException' occurred in System.Runtime.Remoting.dll Evaluation requires a thread to run temporarily. Use the Watch window to perform the evaluation. What does it mean? Can it happens because of runtime versions difference (api 2.0, app 4.0)? I believe the method you are calling through the Immediate

Asynchronous web requests for MetaTrader [closed]

冷暖自知 提交于 2019-11-27 15:13:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am trying to see whether it is feasible to build a custom indicator for MetaTrader that can make asynchronous internet requests, in order to post data to a server with a PHP interface. These requests might take some time for the webserver to process, so I am worried that they will block the indicator from

Evaluation requires a thread to run temporarily. Use the Watch window to perform the evaluation

大憨熊 提交于 2019-11-27 06:43:07
问题 I'm completely stuck. I'm testing MetaTrader API and getting next error when tries to run a method in the Immediate Window of VS 2010: A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll A first chance exception of type 'System.Threading.ThreadAbortException' occurred in System.Runtime.Remoting.dll Evaluation requires a thread to run temporarily. Use the Watch window to perform the evaluation. What does it mean? Can it happens because of runtime

How can I cancel a trade when another is open and keep the open trade for a given duration?

隐身守侯 提交于 2019-11-27 06:38:51
问题 I have written the code below that opens a buy and sell trade (a certain number of pips above and below the ask and bid price) at a specific time. How can I close/cancel one immediately when the other is opened? How can I close the opened trade if it's say X pips in profit or after a minute (depending on which condition is reached first)? I'm a not too sure I've done the right thing in the code below and would really appreciate some help. double spread = Ask-Bid; extern datetime time; extern