Questions tagged [mql4]

MetaQuotes Language 4 (MQL4) is a new built-in language for programming of trading strategies. This language allows to create your own Expert Advisors that make trading management automated and are perfectly suitable for implementing of one's own trade strategies. Besides, one can use MQL4 for creation of one's own Custom Indicators, Scripts, and Libraries.

MetaQuotes Language 4 ( MQL4 ) is a domain specific language for programming of trading strategies built-into a MetaTrader Terminal, a client-side trading software.

This language allows one to create own Expert Advisors that make visualisations, trading management augmented/automated and are perfectly suitable for implementing of one's own trade strategies.

Besides, one can use MQL4 for creation of one's own Custom Indicators, Scripts, Libraries and more complex, distributed/grid processing, solutions.

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

New MQL4, forcedly injected in about 2012, added new concepts, borrowed from 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 code-base, due to injected changes ( having no other option but to re-design DLL interfaces and much more - string type ceased to be a string - a NULL terminated block of chars, to name just few )

The official compiler can be downloaded from here.

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

MetaQuotes head of sales, Anthony Papaevagorou, has announced MetaQuotes no longer intends to issue upgrades to the MetaTrader 4 (MT4) [ reported on 2016-11-15 ]

753 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
  • 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
11
votes
5 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
  • 209
  • 1
  • 2
  • 12
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
8
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,586
  • 3
  • 24
  • 42
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
  • 45,122
  • 42
  • 127
  • 254
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
  • 427
  • 3
  • 13
7
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
  • 665
  • 5
  • 19
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,029
  • 5
  • 27
  • 42
7
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,144
  • 4
  • 32
  • 50
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 Z m u d a
  • 4,882
  • 3
  • 40
  • 36
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
  • 2
5
votes
0 answers

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
  • 49
  • 1
  • 1
  • 5
5
votes
1 answer

Handling exceptions in MQL4

In the Java language one can handle exceptions with a try-catch mechanism. Does it exist any similar behaviour in MQL4? This code throws the error 'array out of range' in the Close[bar] expression and I cannot handle it properly. Any help will be…
JLLMNCHR
  • 1,309
  • 3
  • 22
  • 43
5
votes
3 answers

How to execute an MQL4 program in a server?

I have implemented an expert advisor using the MQL4 language to be executed in MetaTrader. Now, if I need to execute it, I always need to run MetaTrader and attach my EA program to a live currency pair graph in it. I want to know whether there is a…
tnishada
  • 1,054
  • 1
  • 12
  • 23
1
2 3
50 51