Questions tagged [mql4]

MetaQuotes Language 4 (MQL4) is a language used in the MetaTrader 4 online-trading terminal software for programming trading strategies. This language allows the creation of Expert Advisors that make trading management automated and are perfectly suitable for implementation of trade strategies. Also, MQL4 can be used for the creation of Custom Indicators, Scripts, and Libraries.

MetaQuotes Language 4 (MQL4) is a domain-specific language for programming of trading strategies built in to a MetaTrader Terminal — a client-side trading app.

This language allows one to create "Expert Advisors" that make visualisations and trading management augmented/automated and are perfectly suitable for implementation of trade strategies.

MQL4 can also be used for the creation of "Custom Indicators", "Scripts", "Libraries", and more complex, distributed/grid processing solutions.

The structure and syntax of the language is very similar to C.

MQL4, introduced in about 2012, added new concepts borrowed from the not-so-widely accepted MQL5 domain, and legacy MQL4 codes started to have two different compilation/execution modes, depending on a use of a #property strict directive. Also some internalities of the MetaTrader Terminal platform started to be changed, resulting in a need to massively redesign/re-engineer the code-base, due to injected changes (having no other option but to re-design DLL interfaces and much more - e.g., the string type ceased to be a string - but a NULL terminated block of chars).

Check further details at: http://www.mql4.com/

MetaQuotes' head of sales at the time, Anthony Papaevagorou, announced that MetaQuotes no longer intends to issue upgrades to the MetaTrader 4 (MT4), as reported on 2016-11-15.

857 questions
15
votes
2 answers

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

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…
NotEveryDay
  • 153
  • 1
  • 5
14
votes
2 answers

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

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
TopLeft
  • 159
  • 1
  • 7
13
votes
6 answers

How to send/receive data to/from MetaTrader Ternminal 4 with JAVA (or anything!)

I have been working on an algorithm ( Not mine, I am just modifying it ) that predicts when to buy and sell on the FOREX market. I need to be able to open and close orders, dynamically update parameters of the orders ( such as stoploss, maximum stop…
Jay Povey
  • 539
  • 2
  • 6
  • 15
10
votes
4 answers

How to send a POST with a JSON in a WebRequest() call using MQL4?

I would like to send a POST from MQL4-script, using a JSON-format to a Node-server. I've tried the webRequest() standard function in MQL4, based on the following documentation, but it did NOT success. From MQL4 Documentation: Sending simple…
koul
  • 431
  • 2
  • 10
  • 20
10
votes
3 answers

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

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?
Donato Szilagyi
  • 4,279
  • 4
  • 36
  • 53
9
votes
2 answers

What do the shift parameters of iMA() function mean?

Can somebody explain me what is the difference between both shift parameters of the iMA function on an example? According to the MQL4 documentation: ma_shift - Moving Average shift. Indicators line offset relate to the chart by timeframe. shift …
alex555
  • 1,676
  • 4
  • 27
  • 45
8
votes
3 answers

How can I convert Metatrader 4 alert or email indicator signal to Expert Advisor to open trades?

I have been using an indicator to take trades. I didn't develop the indicator, so I only have access to the .ex4 file. How can I extract the take profit, open trade and stop loss values in the alerts or email signals to open trades? Please see a…
iGetIt
  • 695
  • 5
  • 20
8
votes
1 answer

How to decompile a ex4 file new build 600+

If you don't know, an ex4 file is a file created in the MQL language (Auto trading robots). There is a decompiler that can decompile old builds of this type of files, but after build 600 there is no decompiler. I have valuable EAs(Forex robot) that…
Micheal
  • 89
  • 1
  • 1
  • 5
8
votes
4 answers

Can I use languages other than MQL4 on MetaTrader4?

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?
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
7
votes
2 answers

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

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…
TenOutOfTen
  • 467
  • 6
  • 14
7
votes
1 answer

How to return an array from a function in MQL4?

I would like to return an array from my function, how can I do that? Look! int GetOrdresVente(){ int ordrevente; int Tabordresvente[]; for(int j = OrdersTotal() - 1; j >= 0 ; j--){ if(OrderSelect( j, SELECT_BY_POS ) == true){ …
packy
  • 71
  • 1
  • 4
7
votes
1 answer

Asynchronous web requests for MetaTrader

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…
drlobo
  • 2,139
  • 5
  • 32
  • 42
7
votes
3 answers

Call Metatrader MQL4/MQL5 function from imported DLL

I would like to call MQL4 or MQL5 function from my own imported DLL in Metatrader. Is it possible?
Michal Zmuda
  • 5,381
  • 3
  • 43
  • 39
6
votes
2 answers

What is the correct way to set StopLoss and TakeProfit in OrderSend() in MetaTrader4 EA?

I'm trying to figure out if there is a correct way to set the Stop Loss (SL) and Take Profit (TP) levels, when sending an order in an Expert Advisor, in MQL4 (Metatrader4). The functional template is: OrderSend( symbol, cmd, volume, price,…
not2qubit
  • 14,531
  • 8
  • 95
  • 135
6
votes
1 answer

How to pass argument by reference from MQL4 to C++ DLL

I am trying to write a simple program in MQL4 which passes a variable to a C++ DLL function by reference and prints the updated variable value in MQL4. Given below is my code. DLL function: void Test(int* X) { *X = 6; } MQL4 Code #import…
vikas
  • 61
  • 1
  • 2
1
2 3
57 58