MetaQuotes Language II uses several groups of reserved words.
Logical operationsAND, NOT, OR.
MQL II commandsArray, Begin, Break, Continue, Define, Downto, Else, End, Exit, For, If, Input, Then, To, Variable, While.
Reserved words defining the structure of commands of the language are also called "keywords".
Built-in functionsAbs, AccName, AccountName, Alert, ArcCos, ArcSin, ArcTan, Ceil, CloseOrder, Comment, Cos, CurTime,
Day, DayOfWeek, DelArrow, DeleteOrder, DelGlobalVariable, DelObject, Exp, FileClose, FileDelete,
FileOpen, FileReadNumber, FileReadString, FileSeek, FileSize, FileTell, FileWrite, Floor,
GetGlobalVariable, GetIndexValue, GetIndexValue2, GetTickCount, Highest, Hour, iAC, iAD, iADX, iADXEx,
iAlligator, iAO, iATR, iBands, iBandsEx, iBearsPower, iBullsPower, iBWMFI, iCCI, iCCIEx, iCustom,
iDeMarker, iEnvelopes, iForce, iFractals, iGator, iIchimoku, iMA, iMAEx, iMACD, iMACDEx, iMFI, iMom,
iMomEx, iOBV, iOsMA, iRSI, iRSIEx, iRVI, iSAR, iSTO, iWPR, IsDemo, IsFileEnded, IsFileLineEnded,
IsGlobalVariable, IsIndirect, IsTesting, IsTradeAllowed, LastTradeTime, Log, Lowest, MarketInfo, Max, Min,
Minute, Mod, ModifyOrder, Month, MoveObject, Normalize, NumberToStr, Ord, OrderValue, Period, Pow,
Print, PrintTrade, Return, Rand, Round, Seconds, ServerAddress, SetArrow, SetDebugMode,
SetGlobalVariable, SetIndexValue, SetIndexValue2, SetLoopCount, SetObjectText, SetOrder, SetText, Sin,
Sqrt, Srand, StrToTime, Symbol, Tan, TimeDay, TimeDayOfWeek, TimeHour, TimeMinute, TimeMonth,
TimeSeconds, TimeToStr, TimeToStrEx, TimeYear, UserFunction, Year.
Predefined user variables (user-defined variables)Lots, StopLoss, TakeProfit, TrailingStop.
Predefined variables of the trading terminal
AccNum, AccountNumber, Ask, Balance, Bars, Bid, Close, Credit, Equity, FreeMargin, High, Low, Margin,
Open, Point, PriceAsk, PriceBid, PriceHigh, PriceLow, PriceTime, Time, TotalProfit, TotalTrades, Volume.
Predefined parameters of built-in functions (macros)MODE_CLOSE, MODE_DETAILS, MODE_EMA, MODE_FILE, MODE_FIRST, MODE_GATORJAW,
MODE_GATORLIPS, MODE_GATORTEETH, MODE_HIGH, MODE_KIJUNSEN, MODE_LWMA,
MODE_LOW, MODE_LOWER, MODE_MAIN, MODE_MINUSDI, MODE_OPEN, MODE_PLUSDI,
MODE_SECOND, MODE_SENKOUSPAN, MODE_SENKOUSPANA, MODE_SENKOUSPANB,
MODE_SIGNAL, MODE_SMA, MODE_SMMA, MODE_STOPLOSS, MODE_TAKEPROFIT,
MODE_TENKANSEN, MODE_TIME, MODE_UPPER, MODE_VALUES, MODE_VOLUME, OBJ_FIBO,
OBJ_HLINE, OBJ_SYMBOL, OBJ_TEXT, OBJ_TRENDLINE, OBJ_VLINE, OP_BUY, OP_BUYLIMIT,
OP_BUYSTOP, OP_SELL, OP_SELLLIMIT, OP_SELLSTOP, PRICE_CLOSE, PRICE_HIGH,
PRICE_LOW, PRICE_MEDIAN, PRICE_OPEN, PRICE_TYPICAL, PRICE_WEIGHTED, SEEK_CUR,
SEEK_END, SEEK_SET, STYLE_SOLID, STYLE_DASH, STYLE_DOT, STYLE_DASHDOT,
STYLE_DASHDOTDOT, SYMBOL_ARROWDOWN, SYMBOL_ARROWUP, SYMBOL_CHECKSIGN,SYMBOL_STOPSIGN, SYMBOL_THUMBSDOWN, SYMBOL_THUMBSUP, TIME_DATE, TIME_MINUTES,
TIME_SECONDS, VAL_CLOSEPRICE, VAL_CLOSETIME, VAL_COMMENT, VAL_COMMISSION,
VAL_LOTS, VAL_OPENPRICE, VAL_OPENTIME, VAL_PROFIT, VAL_STOPLOSS, VAL_SWAP,
VAL_SYMBOL, VAL_TAKEPROFIT, VAL_TICKET, VAL_TYPE.
Actually, the above reserved words are macros, i.e. the syntax analyzer replaces them with numerical
values. Macros were introduced to simplify the process of writing the function calls for the user: more
convenient and mnemonically significant words can be used instead of the numerical values of parameters
of some functions. The same applies to the names of colors.
Colors
AliceBlue, AntiqueWhite, Aqua, Aquamarine, Azure, Beige, Bisque, Black, BlanchedAlmond, Blue,
BlueViolet, Brown, BurlyWood, CadetBlue, Chartreuse, Chocolate, Coral, CornflowerBlue, Cornsilk,
Crimson, Cyan, DarkBlue, DarkCyan, DarkGoldenrod, DarkGray, DarkGreen, DarkKhaki, DarkMagenta,
DarkOliveGreen, DarkOrange, DarkOrchid, DarkRed, DarkSalmon, DarkSeaGreen, DarkSlateBlue,
DarkSlateGray, DarkTurquoise, DarkViolet, DeepPink, DeepSkyBlue, DimGray, DodgerBlue, FireBrick,
FloralWhite, ForestGreen, Fuchsia, Gainsboro, GhostWhite, Gold, Goldenrod, Gray, Green, GreenYellow,
Honeydew, HotPink, IndianRed, Indigo, Ivory, Khaki, Lavender, LavenderBlush, LawnGreen, LemonChiffon,
LightBlue, LightCoral, LightCyan, LightGoldenrod, LightGreen, LightGrey, LightPink, LightSalmon,
LightSeaGreen, LightSkyBlue, LightSlateGray, LightSteelBlue, LightYellow, Lime, LimeGreen, Linen,
Magenta, Maroon, MediumAquamarine, MediumBlue, MediumOrchid, MediumPurple, MediumSeaGreen,
MediumSlateBlue, MediumSpringGreen, MediumTurquoise, MediumVioletRed, MidnightBlue, MintCream,
MistyRose, Moccasin, NavajoWhite, Navy, OldLace, Olive, OliveDrab, Orange, OrangeRed, Orchid,
PaleGoldenrod, PaleGreen, PaleTurquoise, PaleVioletRed, PapayaWhip, PeachPuff, Peru, Pink, Plum,
PowderBlue, Purple, Red, RosyBrown, RoyalBlue, SaddleBrown, Salmon, SandyBrown, SeaGreen,
Seashell, Sienna, Silver, SkyBlue, SlateBlue, SlateGray, Snow, SpringGreen, SteelBlue, Tan, Teal, Thistle,
Tomato, Turquoise, Violet, Wheat, White, WhiteSmoke, Yellow, YellowGreen.
All the reserved words are case-insensitive, i.e. they may be written in lower as well as in upper case.
Predefined user variablesIt is often necessary to change certain parameters in an already written Expert Advisor which affect its
operation. In order to avoid manual editing of the Advisor code and its critical variables each time such
changes are made, an approach similar to that used in the MetaQuotes system was applied: four
parameters were taken out to the "Properties" table (Menu Files of the MetaEditor – Properties... –
"Processing" tab) of the Expert Advisor:• Lots – number of lots;
• StopLoss – Stop Loss level in points;
• TakeProfit – Take Profit level in points;
• TrailingStop – Trailing Stop level in points.
[You must be registered and logged in to see this image.]Initial values of these variables may be entered through the "Properties" table of the Expert Advisor or
changed in a special settings dialog box ("Settings" tab) called by pressing
F7 or via the menu (
Charts –Expert Advisors – Properties). These variables can't be modified from the programme.
[You must be registered and logged in to see this image.]