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

Forcebly stop EA in OnTick()

I am making a EA for backTest. Normally program works like this. Ontick() is called until the end of certain period. OnDeinit() OnTester() are called. However now I want to stop in OnTick() and goto 2). like this, void OnTick() { if (cnt >…
whitebear
  • 11,200
  • 24
  • 114
  • 237
5
votes
6 answers

How to calculate (add) datetime values in MQL4?

With MQL4 I have troubles in handling datetime. What I want to do is put datetime in array by month or by year. For now I do in this way. datetime myDate; myDate[0] = D'2010.01.01 00:00'; myDate[1] = D'2010.02.01 00:00'; myDate[2] = D'2010.03.01…
whitebear
  • 11,200
  • 24
  • 114
  • 237
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,551
  • 5
  • 24
  • 50
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,315
  • 1
  • 16
  • 24
4
votes
1 answer

What function would you use to list the symbols?

Is there a way to set a condition that includes a list of currency symbol pairs and be alerted when that condition is met? What function would you use to list the symbols? Thanks in advance. The following code gives you a rough idea of what i'm…
4
votes
6 answers

How to get current milliseconds in MetaTrader4 Terminal?

How can I get current milliseconds from MQL4 using an Expert Advisor. i.e.: in Java we can get current milliseconds using system.currenttimemillis()
Nitin
  • 2,701
  • 2
  • 30
  • 60
4
votes
2 answers

How to post from MetaTrader Terminal 5 MQL 5 a request to my nodejs server, which is running locally on my MT5 host?

I'm trying to get FX rates in my nodejs server and socke.io emit them to the client, while running MetaTrader Terminal 5 or 4. So I guess I have to use MQL4/5. I know how the handle the request in my nodejs server. What I dont know is where to write…
Georgi Antonov
  • 1,581
  • 21
  • 40
4
votes
1 answer

Simple function to read file from an URL to a string buffer ( C++ / MQL{4|5} using WinInet.dll )

I am looking for a simple function which is able to read a text or binary file from the internet into a string variable. It´s unbelievable that I could not find anything in the web, just low level descriptions of all the WinInet functions and…
Doerk
  • 71
  • 8
4
votes
2 answers

MQL4 Function pointer / function callback solution

As far as i have seen function pointers do not exist in MQL4. As a workaround i use: // included for both caller as callee side class Callback{ public: virtual void callback(){ return; } } Then in the source where a callback is passed…
Joel Box
  • 429
  • 1
  • 6
  • 12
4
votes
1 answer

R Project and MQL4 convert forecast object in R to Vector

I am using the forecast package in R and this creates a forecast object. I am wanting to convert the forecast into a vector so that I can use 7bits wrapper and use R in MQL4 code. Example forecast code: > forecast(fit, h=5) Point Forecast Lo…
Jerry
  • 133
  • 10
4
votes
1 answer

Server to Client Communication Architecture

We have a "trade copying" software, which, as the name suggests is used to mirror trades from one trader(sender) to multiple other traders (receivers). It has three main components: 1. Sender client. 2. Server. 3. Receiver client. Sender -> Server…
Aziz
  • 534
  • 5
  • 23
3
votes
3 answers

How to code and compile mql4 and mql5 language in VS Code?

I moved to mql4 and mql5 programming language. But, MetaEditor is very noob to code with, so I want to code mql4 language and compile with VS Code. If you have any solution please share with us..... Thanks
3
votes
2 answers

How to get the number of decimal places for every Symbol() price

Certain Currency pairs display values to 5 decimal places (EURUSD), others 4 and so on. I wrote the code below to return the integer value of the decimal places minus one. This function just takes into consideration a few pairs. I would like to…
TenOutOfTen
  • 467
  • 6
  • 14
3
votes
2 answers

How can I use iOpen(), iClose(), iLow() and iHigh() to find these pinbars?

I want to find the pinbars circled in the attached image below. For the one on the right, the body is about 1/5th of the candle size and for the one on the left, let's say the body is 1/7th the size candle size and it also has a wick of 1/7th the…
SuperHueman
  • 165
  • 15
3
votes
2 answers

How can I calculate lot size risking X% of account balance

My question is in two closely related parts: Given the entry price and stop loss, how can I calculate my lot size so that 2.5% of my current account balance would be risked on trades? Also in cases where the 2.5% lot size is not a tradable lot…
1
2
3
57 58