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

How can I write an mt4 indicator that draws a rectangle and horizontal lines over first 6 hours of hourly candles

I am a quite new to mql4 coding. I would like to know how I write an indicator that does the following, based on the image below: Draw a rectangle over the current day hour chart that covers the highest and lowest price points of the first 6 hours…
hutfelt
  • 321
  • 1
  • 8
3
votes
1 answer

Algotrading: How to incorporate this type of trailing stop?

I currently have a system that opens a trade almost every 5 minutes. I'm currently trying to wrap my head around creating a trailing stop loss that does something like this: scan all open orders every tick and modify them, if they have not been…
3
votes
2 answers

How to check if a ticket is still open or has been closed?

If I open a position with OrderSend setting a take profit and a stop loss, how can I check if it is still open or, on the contrary, it has been closed because of the stop_loss or the take profit?
Bub Espinja
  • 4,029
  • 2
  • 29
  • 46
3
votes
2 answers

MQL4 run EA on all symbols by adding to just one chart

In MetaTrader4 Terminal I write a simple alert EA I would like to run my EA on all FOREX Majors and FOREX Minors, I've got my code all done, but I want it to automatically run on all symbols in my [ Market Watch ] panel. Here is my code, it is very…
3
votes
2 answers

Compiling MQL4 via command line through wine metaeditor.exe

I'm trying to get to a point where I can compile/syntax check via command line so I can avoid using metaeditor for code management. I'm using this command (also attempted with /s and /log): wine metaeditor.exe /compile:"MQL4/Experts/MACD…
udjamaflip
  • 682
  • 1
  • 8
  • 24
3
votes
2 answers

A datetime arithmetic in MQL4

I would like to define a datetime type variable that is a result of a simple arithmetic operation between datetime type variables. I've defined: datetime duration = ( TimeCurrent() - OrderOpenTime() ); datetime TmStop = StringToTime( "1970.01.01…
perjliv
  • 91
  • 3
  • 12
3
votes
4 answers

How to return a string from a C++ DLL into a MetaTrader 4 code-execution ecosystem?

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

Converting XGBoost tree structure dump file to MQL4 (C like language) code

I have a dump file of XGBoost tree structure trained in Python. The structure has 377 trees, and file has approximately 50,000 lines. I would like to convert this structure to MQL4 code, or C code so to say. The text file looks something like…
Gursel Karacor
  • 1,137
  • 11
  • 21
3
votes
2 answers

Can't run a simple Expert Advisor with [ nquotes ] using Visual Studio 2015, MetaTrader Terminal 4

Can't run simple expert advisor. Wnd.dll - file from "bin" folder, created with VS2015. Wnd.dll file is inside a correct "MQL4\Libraries\" folder.So I tried to run this Advisor on a Live mode but nothing happened. Please help what I am doing…
Alexey Gapon
  • 73
  • 2
  • 11
3
votes
2 answers

How to pull +DI and -DI values from an iADX() indicator in MQL4 / MQL5?

I'm a noob at MQL4 and I am writing my first EA. My goal is to get the variables of the +DI and -DI of the ADX Indicator. I used the iADX() function as shown here: double a; int OnInit() { a = iADX( NULL, 0, 0, PRICE_CLOSE, MODE_PLUSDI, 0 ); …
3
votes
3 answers

How to code a Multidimensional Dynamic Array?

How to code a Multidimensional Dynamic Array in MQL4? I'm fairly new to coding MQL4. Currently coding my first EA and just learnt about Arrays. I was wondering, how to code a dynamic array? What I'm trying to do is when my EA is initialized, for the…
laman
  • 552
  • 6
  • 18
3
votes
1 answer

MQL4 - ERROR 4111 when calling OrderSend() method

I am trying to place order, but my call to OrderSend() method ( https://docs.mql4.com/trading/ordersend )is failing: 2016.08.01 00:51:09.710 2016.07.01 01:00 s EURUSD,M1: OrderSend error 4111 void OnTick() { if ( OrdersTotal() == 0 ){ …
user285594
3
votes
1 answer

Writing an expert adviser in [ MQL4 ]

So if I wanted an EA in MQL4 that took the open price and when current price was 10 pips below the open it places a buy order and when it was 10 pips above the open it sold. Only one order at a time and the open changed daily. Q1: How could that run…
3
votes
3 answers

Fire and catch an event when stopLoss or takeProfit happens

In MQL4, I know how to set stopLoss and takeProfit. However, I would like to do something else when such events actually take place. Is there any event listener associated with such?
user1819047
  • 667
  • 9
  • 18
3
votes
2 answers

C++ Access violation write to 0x00000000 in dll in mql4

First, I am new to C++ (nearly a week into it), so forgive me if this is obvious. Also, I have hunted through many posts with similar issues. Either my understanding is just not developed enough, or none had relevant info to help me understand…
MehZhure
  • 99
  • 1
  • 8
1 2
3
57 58