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
2
votes
3 answers

How can someone send data from MetaTrader 4/5 Terminal to external server?

this is somehow intended to (maybe) be(come) a guideline post in terms of MetaTrader 4/5 and its corresponding language MQL4 both set into context with sending data to external servers. In my special case I am building a Django/Python based web…
JSRB
  • 2,492
  • 1
  • 17
  • 48
2
votes
1 answer

MQL4 automatic stop

My Martingale EA should be stopped automatically if the previously manually set limit has been reached or exceeded. The last trade should expire normally and not be interrupted. So far, I've tried the following code, without interruption, etc. the…
user12178191
2
votes
0 answers

ERR_TRADE_NOT_ALLOWED only for debugging mode

I try to debug my code but I get error 4109 (ERR_TRADE_NOT_ALLOWED) when I send order: orderId = OrderSend( Symbol(), orderType, lotVolume, price, 3, Bid - StopLoss * Point, Bid + TakeProfit * Point ); This common error for not…
Pavel
  • 2,005
  • 5
  • 36
  • 68
2
votes
1 answer

Can't calculate the right Volume RSI in MQL4 with a functioning Pine-Script Example

I want to "translate" a Pine-Script to MQL4 but I get the wrong output in MQL4 compared to the Pine-Script in Trading-view. I wrote the Indicator in Pine-Script since it seems fairly easy to do so. After I got the result that I was looking for I…
2
votes
1 answer

How can I solve the duplicates of pending order issues?

My code below places sell pending orders when certain candle patterns are met on the H_1 chart. But duplicate pending orders are created when I change the chart timeframe and return to H_1. Also old orders that should have hit stop loss or take…
SuperHueman
  • 165
  • 15
2
votes
2 answers

deleting line from file MQL4

I am saving all the trades done by my EA into a CSV file. When a Trade is closed by the EA, I have to add string "Book Profit" to the end of particular line from the file. eg: Below is the line that is saved in the file while trade is open "Buy…
2
votes
3 answers

Embedding a MQL4 custom indicator code in an Expert Advisor

This is my first post on Stackoverflow although I've visited here for years. I have read the message guidelines so I'll be as succinct and specific as possible. I have been attempting to embed the code of a Custom Indicator directly in an Expert…
2
votes
3 answers

Creating textfile with MQL4

I am trying to create a textfile with MQL4. No sucess. It just doesn't work. A very simple script: void OnStart() { string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH); string…
Alexsander Santos
  • 107
  • 1
  • 2
  • 7
2
votes
4 answers

How to return an object or struct from a method in MQL?

struct Person { string FirstName; string LastName; }; class Builder { public: Person Builder::Build() { Person person; person.FirstName = "FirstName"; person.LastName = "LastName"; return…
Dynamic
  • 1,553
  • 2
  • 19
  • 25
2
votes
0 answers

MQL4 my first EA overtrades if I increase the amount of conditions it calculates

I have created an expert advisor that calculates some conditions and gives a value either long or short for each condition (+or- 0.1 lots), it then sums all the conditions to give a net long or short position. It should then either open a new order…
ken
  • 21
  • 3
2
votes
3 answers

How are MQL4 Orders ordered by default?

When using OrderSelect() in mql4, are the orders ordered according to the ticket number by default? My intention is to use OrderModify() on orders starting from the first that was opened to the most recent.
Paul Wakhungu
  • 322
  • 2
  • 18
2
votes
1 answer

How to execute an OrderSend() function of MQL4 or MQL5 using cmd?

How to execute an OrderSend() function of MQL4 or MQL5 language using cmd script ?
2
votes
1 answer

How to pass data from MQL4 to C# DLL

I would like to ask how to pass some kind of data, like string to my C# DLL. This questions has been answered for C++: How to pass argument by reference from MQL4 to C++ DLL However in my case I want my C# code to get this value from MQL4 and then…
Iason
  • 209
  • 3
  • 11
  • 38
2
votes
1 answer

MQL4 cannot find a file

The following code cannot find a file and returns error 5002, wrong file name. I include also a file explorer picture showing the file is in existence. Can you please help me why the file is not found? if…
Jean
  • 137
  • 1
  • 13
2
votes
4 answers

What is the reason for the error 'invalid ticket for Order close function' in mql4?

In my mql4 Expert Advisor, I've written this function to close all the buy trades at once. When I test it via the Strategy Tester, it closes some buy trades, but for a few other buy trades it returns the: OrderClose error 4051:invalid ticket for…
user6534695