mql4

Managing JSON Array format in MQL4 script

谁都会走 提交于 2019-12-06 14:28:19
I would need to get data from inside a JSON Array. I use a call to WebRequest() function to get an order list from my db, thru a nodejs(api) and then I got the following JSON-data format e.g: [{"orderid": 123556, "ordertype": 0, "ordercurrency": "EURUSD", "orderdt": "2016-12-03 03:00:00" }, {"orderid": 123457, "ordertype": 0, "ordercurrency": "GBPUSD", "orderdt": "2016-12-03 03:15:00" } ] Any idea how to transform it to a normal array in order to manage data? Thank you. /Koul JSON Serialization and Deserialization library works pretty well. You can include it and finish your task within a

Why MQL4 OrderModify() will not modify the order when backtesting?

ぐ巨炮叔叔 提交于 2019-12-06 06:10:09
I'm trying to ADD a stop loss to my open market orders in MetaTrader 4 when a position gets 100 pips "to the good" which is to be equal to the Order Open Price; OrderStopLoss() == OrderOpenPrice() But this isn't happening. I've added Print() & GetLastError() functions and nothing is coming up in the journal, so it must be something in my coding - but cannot see what would be wrong. OK this is what I have so far, one for loop for the buy, one for the sell. I've also Normalized the "doubles" as I have been advised to do & have also declared the BuyMod & SellMod to "true" at the very top. This

How to read a JSON from a URL in MQL5?

*爱你&永不变心* 提交于 2019-12-05 07:40:22
问题 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" } ] } 回答1: 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

Troubles with zmq_bind() in ZeroMQ binding for MQL4 language

拜拜、爱过 提交于 2019-12-05 06:14:57
问题 I am working on MT4 and used wrapper mql4zmq.dll as given in link https://github.com/AustenConrad/mql4zmq As I have followed all instruction and successfully loaded DLL as well as lib file at specific locations from pre-compiled. But it can not bind or connect with socket through zmq_connect(,) or zmq_bind(,) . Please some one help me to solve this problem. I am posting my code here // Include the libzmq.dll abstraction wrapper. #include <mql4zmq.mqh> //+--------------------------------------

How to keep a 10 pip profit gap between stop loss and current price as profits increase

巧了我就是萌 提交于 2019-12-04 21:35:32
问题 I am trying to add another condition to the solution in this post. I want the stop loss to move by 10 pips when a trade is in 10 pips profit. To be more specific, say I've set a pending buy order and the stop loss is 10 pips below the open price and the take profit is 50 pips. If the trade is 10 pips in profit, then the stop loss would move 10 pips upwards, if the trade moves to 20 pips in profit then the stop loss would move another 10 pips upwards, and the same would occur for 30 and 40

Can I use languages other than MQL4 on MetaTrader4?

元气小坏坏 提交于 2019-12-04 04:56:42
I have a task of migrating a C# market strategy to MetaTrader. Is there any way to automate that job? (For example, is it possible to parse C# into it's AST, then make the translation?) Does MetaTrader accept other languages by any means? Approach the task Bottom-Up -- Architecture-wise Yes, you can simplify the trouble and make MT4 become a Node, which is immediately connected peer-to-peer to your current C# Market Strategy. This alowed me to operate a cluster-based computing communicating massively parallel with a crowd of MT4 nodes. MT4 can become anEventFEED -er Node via a more complex "

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 set order few pips above order initiation bar in MQL4

眉间皱痕 提交于 2019-12-03 21:52:54
I would like to create a stoploss order that will be placed above the high of the previous order's initiation bar in case this is a Sell order OR below the low of the previous order's initiation bar in case this is a Buy order. Here is a picture to illustrate the issue ( the example depicts a sell order case ): Any idea how to do that? The code below works fine if I use stoploss that is fixed. If I replace the stoploss with variables that are based on High or Low no orders are fired. Here is my code: //| Expert initialization function | //+------------------------------------------------------

Executing an URL from MQL4

落爺英雄遲暮 提交于 2019-12-03 21:49:14
On my MQL4 Code I need to execute an External url/link in order to update a table, I have Added the URL in the Allowed URL List Option. However I got the following error : Any Idea how to solve this problem ? Thanks . PS: I am using MT4 Build 840 This warning reminds you to set ( check [ x ] ref. Fig1 below ) permit(s) to do so in your MT4 Terminal Tools -> Options ( Ctrl + O ) Both the [Allow automated trading (Expert advisor per se )] and [ Allow WebRequest for listed URL: / Add a properly formatted link...] must be checked [ x ] as Allow... For any further problem resolution, the MCVE

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