Skip to content

MQL5 function reference

This page is generated automatically from the TMChart MQL5 interpreter: the functions listed here run in TMChart; a program that calls a function not listed here is rejected when it loads, with the reason (nothing is faked). Names are case-sensitive, as in MetaTrader 5. To create and run a program, see MQL5.

EA: OnInit, OnTick, OnDeinit, OnTimer, OnTrade and OnTradeTransaction. Indicator: OnCalculate (both forms). Script: OnStart (runs once). An EA’s orders go to the TMChart broker: Backtest, SIMULATOR, replay and, on the LIVE account, only through an automation you turn on. MetaTrader 5 never runs the program.

Write to the editor console (and to the automation log) and handle the error code.

Alert · Comment · GetLastError · Print · printf · PrintFormat · ResetLastError · SetUserError

Numeric functions, with the Math... names and the short ones (fabs, pow…).

acos · asin · atan · atan2 · ceil · cos · exp · fabs · floor · fmax · fmin · fmod · log · log10 · MathAbs · MathArccos · MathArccosh · MathArcsin · MathArcsinh · MathArctan · MathArctan2 · MathArctanh · MathCeil · MathCos · MathCosh · MathExp · MathExpm1 · MathFloor · MathIsValidNumber · MathLog · MathLog10 · MathLog1p · MathMax · MathMin · MathMod · MathPow · MathRand · MathRound · MathSin · MathSinh · MathSqrt · MathSrand · MathTan · MathTanh · NormalizeDouble · pow · rand · round · sin · sqrt · srand · tan

String functions and conversions between text, numbers, dates, colors and enums.

CharArrayToString · CharToString · ColorToString · DoubleToString · EnumToString · IntegerToString · ShortToString · StringAdd · StringBufferLen · StringCompare · StringConcatenate · StringFill · StringFind · StringFormat · StringGetCharacter · StringInit · StringLen · StringReplace · StringSetCharacter · StringSplit · StringSubstr · StringToCharArray · StringToColor · StringToDouble · StringToInteger · StringToLower · StringToTime · StringToUpper · StringTrimLeft · StringTrimRight · TimeToString

Broker server time (TimeCurrent), PC time and counters.

GetMicrosecondCount · GetTickCount · GetTickCount64 · Sleep · StructToTime · TimeCurrent · TimeDaylightSavings · TimeGMT · TimeGMTOffset · TimeLocal · TimeToStruct · TimeTradeServer

Dynamic and static arrays, series order (ArraySetAsSeries) and copies.

ArrayBsearch · ArrayCopy · ArrayFill · ArrayFree · ArrayGetAsSeries · ArrayInitialize · ArrayInsert · ArrayIsDynamic · ArrayIsSeries · ArrayMaximum · ArrayMinimum · ArrayRange · ArrayRemove · ArrayResize · ArrayReverse · ArraySetAsSeries · ArraySize · ArraySort · ArraySwap · ZeroMemory

Symbol data (SymbolInfo...), chart and timeframe.

Digits · Period · PeriodSeconds · Point · Symbol · SymbolExist · SymbolInfoDouble · SymbolInfoInteger · SymbolInfoMarginRate · SymbolInfoString · SymbolInfoTick · SymbolIsSynchronized · SymbolName · SymbolSelect · SymbolsTotal

Bars and series of the symbol in any timeframe (CopyRates, iClose…).

Bars · CopyClose · CopyHigh · CopyLow · CopyOpen · CopyRates · CopyRealVolume · CopySpread · CopyTickVolume · CopyTime · iBars · iBarShift · iClose · iHigh · iHighest · iLow · iLowest · iOpen · iRealVolume · iSpread · iTickVolume · iTime · iVolume · SeriesInfoInteger

Data of the running account, of the program, and the OnTimer timer.

AccountInfoDouble · AccountInfoInteger · AccountInfoString · EventKillTimer · EventSetMillisecondTimer · EventSetTimer · IsStopped · MQLInfoInteger · MQLInfoString · TerminalInfoInteger · TerminalInfoString

Technical indicators by handle and CopyBuffer, and iCustom for your own MQL5 indicator.

BarsCalculated · CopyBuffer · iAC · iAD · iADX · iADXWilder · iAlligator · iAMA · iAO · iATR · iBands · iBearsPower · iBullsPower · iBWMFI · iCCI · iChaikin · iCustom · iDEMA · iDeMarker · iEnvelopes · iForce · iFractals · iFrAMA · iGator · iIchimoku · iMA · iMACD · iMFI · iMomentum · IndicatorCreate · IndicatorRelease · iOBV · iOsMA · iRSI · iRVI · iSAR · iStdDev · iStochastic · iTEMA · iTriX · iVIDyA · iVolumes · iWPR

Buffers and plots of an indicator written in MQL5 (OnCalculate).

IndicatorSetDouble · IndicatorSetInteger · IndicatorSetString · PlotIndexGetInteger · PlotIndexSetDouble · PlotIndexSetInteger · PlotIndexSetString · SetIndexBuffer

Orders, positions and history. Orders go only to the TMChart broker (see below).

HistoryDealGetDouble · HistoryDealGetInteger · HistoryDealGetString · HistoryDealGetTicket · HistoryDealSelect · HistoryDealsTotal · HistoryOrderGetDouble · HistoryOrderGetInteger · HistoryOrderGetString · HistoryOrderGetTicket · HistoryOrderSelect · HistoryOrdersTotal · HistorySelect · HistorySelectByPosition · OrderCalcMargin · OrderCalcProfit · OrderCheck · OrderGetDouble · OrderGetInteger · OrderGetString · OrderGetTicket · OrderSelect · OrderSend · OrderSendAsync · OrdersTotal · PositionGetDouble · PositionGetInteger · PositionGetString · PositionGetSymbol · PositionGetTicket · PositionSelect · PositionSelectByTicket · PositionsTotal

#include <Trade\Trade.mqh> (and the other files in your terminal’s MQL5\Include folder) uses the original file of the MetaTrader 5 installed on the PC: the CTrade class and the ones it uses run on the functions on this page. #include "file.mqh" reads from the program’s own folder.

They exist in MetaTrader 5 and are planned; a program that calls them is rejected when it loads.

CopyTicks · CopyTicksRange

DLLs and #import, .ex5 without source code, chart objects (ObjectCreate, ChartEvent), panels and Canvas, files, network (WebRequest, e-mail, push), databases, OpenCL, matrices/vectors and the economic calendar.

Total: 257 functions.