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.
Events
Section titled “Events”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.
Output and errors
Section titled “Output and errors”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
Text and conversion
Section titled “Text and conversion”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
Date and time
Section titled “Date and time”Broker server time (TimeCurrent), PC time and counters.
GetMicrosecondCount · GetTickCount · GetTickCount64 · Sleep · StructToTime · TimeCurrent · TimeDaylightSavings · TimeGMT · TimeGMTOffset · TimeLocal · TimeToStruct · TimeTradeServer
Arrays
Section titled “Arrays”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
Section titled “Symbol”Symbol data (SymbolInfo...), chart and timeframe.
Digits · Period · PeriodSeconds · Point · Symbol · SymbolExist · SymbolInfoDouble · SymbolInfoInteger · SymbolInfoMarginRate · SymbolInfoString · SymbolInfoTick · SymbolIsSynchronized · SymbolName · SymbolSelect · SymbolsTotal
Price series
Section titled “Price series”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
Account, terminal and events
Section titled “Account, terminal and events”Data of the running account, of the program, and the OnTimer timer.
AccountInfoDouble · AccountInfoInteger · AccountInfoString · EventKillTimer · EventSetMillisecondTimer · EventSetTimer · IsStopped · MQLInfoInteger · MQLInfoString · TerminalInfoInteger · TerminalInfoString
Indicators
Section titled “Indicators”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
Custom indicator
Section titled “Custom indicator”Buffers and plots of an indicator written in MQL5 (OnCalculate).
IndicatorSetDouble · IndicatorSetInteger · IndicatorSetString · PlotIndexGetInteger · PlotIndexSetDouble · PlotIndexSetInteger · PlotIndexSetString · SetIndexBuffer
Trading
Section titled “Trading”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
Standard Library and #include
Section titled “Standard Library and #include”#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.
Not available yet
Section titled “Not available yet”They exist in MetaTrader 5 and are planned; a program that calls them is rejected when it loads.
CopyTicks · CopyTicksRange
Outside the interpreter
Section titled “Outside the interpreter”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.