MQL5 is the C-like language many traders use for desktop indicators. You can paste an MQL5 indicator (a .mq5 file) into the ZoroCharts script editor and run it on any chart. Plots, levels, settings, chart objects, buttons and timers work.
- Indicators only. Scripts can draw and calculate. They can never place, change or close orders.
- It runs in a sandbox in your browser. The code has no access to your account, your files or the network. A script that runs too long or uses too much memory is stopped.
- Our own engine runs it. TradeZoro reads the MQL5 source and runs it with its own engine. Results can differ in small ways from other platforms (see "Known differences").
Education only. Not financial advice.
1. Paste and run
- Open ZoroCharts and press the script editor button in the toolbar.
- At the top of the editor pick MQL5.
- Press New, select all the text and paste your indicator. Or use More, Import file to open a
.mq5file. - The editor checks the code as you type. Problems show with their line number; click one to jump to it.
- Press Add to chart. Give it a name and press Save to keep it in My scripts.
Each input and sinput becomes a setting. Open the indicator's settings on the chart to change them; the indicator recalculates straight away. input group "Name" lines become headings in the settings.
Five examples are in the editor's Examples tab: a moving-average cross with buttons, RSI with levels, a Bollinger fill, session boxes, and a bar countdown.
2. What is supported
| Area | Supported |
|---|---|
| Language | int, uint, long, ulong, short, char, uchar, double, float, bool, string, datetime, color; enums; structs with fields; fixed and dynamic arrays, ArraySetAsSeries; functions with references and default values; static and const; #property, #define (also with arguments), #include of standard headers (built in, nothing to install). |
| Events | OnInit, both forms of OnCalculate (all price arrays, or one price[]), OnDeinit, OnTimer with EventSetTimer / EventSetMillisecondTimer, OnChartEvent (object click, chart click, key press, object drag, edit finished, chart change). prev_calculated works, so only new bars are recalculated on each update. |
| Plots | DRAW_LINE, DRAW_SECTION, DRAW_HISTOGRAM, DRAW_HISTOGRAM2, DRAW_ARROW, DRAW_ZIGZAG, DRAW_FILLING, DRAW_BARS, DRAW_CANDLES and every DRAW_COLOR_* type; INDICATOR_DATA, INDICATOR_COLOR_INDEX, INDICATOR_CALCULATIONS; colours, styles, widths, labels, empty value, draw begin, shift; chart window or own window; levels, minimum and maximum. |
| Indicator handles | iMA (all four methods), iRSI, iMACD, iBands, iATR, iStochastic, iCCI, iADX, iMomentum, iSAR, iEnvelopes, iStdDev and more (list below), read with CopyBuffer. iCustom runs another MQL5 indicator saved in your My scripts, by its name. |
| Chart objects | Horizontal and vertical lines, trend lines, rectangles, text, arrows, and the on-screen objects: labels, buttons (with on/off state), edit boxes and rectangle labels, placed by corner and distance. Buttons and edit boxes can be clicked and typed in, and raise OnChartEvent. |
| Messages | Print goes to the browser console, Comment shows on the chart, Alert shows a chart message and plays the alert sound. |
3. Not supported
These give one clear message with the line number, "not supported in indicators on TradeZoro":
- Trading:
OrderSend, the trade classes, positions, orders, deals and account functions. - Files, DLL imports, web requests, sockets, e-mail and push messages.
- Expert advisor and script events such as
OnTick,OnTrade,OnStart. - Classes, struct methods, templates and pointers to objects. Write plain functions that take a struct by reference instead.
4. Known differences
- Prices come from the chart you are looking at. Other symbols or timeframes in
iClose,CopyRatesand handles use the chart's own bars. - Tick volume is the chart's volume, and spread is 0.
- Timers pause while the browser tab is hidden and catch up once when you come back.
- Fonts are matched to the closest font your device has.
5. Built-in functions
416 built-in functions in 14 groups. Hover a name to see its form.
Arrays 22
ArrayBsearchArrayCompareArrayCopyArrayFillArrayFreeArrayGetAsSeriesArrayInitializeArrayInsertArrayIsDynamicArrayIsSeriesArrayMaximumArrayMinimumArrayPrintArrayRangeArrayRemoveArrayResizeArrayReverseArraySetAsSeriesArraySizeArraySortArraySwapZeroMemory
Chart 32
ChartFirstChartGetDoubleChartGetIntegerChartGetStringChartIDChartIndicatorNameChartIndicatorsTotalChartNavigateChartNextChartPeriodChartPriceOnDroppedChartRedrawChartSetDoubleChartSetIntegerChartSetStringChartSetSymbolPeriodChartSymbolChartTimeOnDroppedChartTimePriceToXYChartWindowFindChartWindowOnDroppedChartXOnDroppedChartXYToTimePriceChartYOnDroppedWindowBarsPerChartWindowFindWindowFirstVisibleBarWindowOnDroppedWindowPriceMaxWindowPriceMinWindowRedrawWindowsTotal
Common 28
AlertCheckPointerCommentDebugBreakEventChartCustomEventKillTimerEventSetMillisecondTimerEventSetTimerGetLastErrorIsConnectedIsDllsAllowedIsOptimizationIsStoppedIsTestingIsVisualModeMarketInfoMQLInfoIntegerMQLInfoStringPlaySoundPrintPrintFormatResetLastErrorSetUserErrorTerminalInfoDoubleTerminalInfoIntegerTerminalInfoStringTranslateKeyUninitializeReason
Conversion 24
CharArrayToStringCharToStrCharToStringColorToARGBColorToStringDoubleToStrDoubleToStringEnumToStringIntegerToStrIntegerToStringNormalizeDoubleShortArrayToStringShortToStringStringToCharArrayStringToColorStringToDoubleStringToIntegerStringToShortArrayStringToTimeStrToDoubleStrToIntegerStrToTimeTimeToStrTimeToString
Custom indicators 10
IndicatorDigitsIndicatorSetDoubleIndicatorSetIntegerIndicatorSetStringIndicatorShortNamePlotIndexGetIntegerPlotIndexSetDoublePlotIndexSetIntegerPlotIndexSetStringSetIndexBuffer
Date and time 28
DayDayOfWeekDayOfYearGetMicrosecondCountGetTickCountGetTickCount64HourMinuteMonthSecondsSleepStructToTimeTimeCurrentTimeDayTimeDaylightSavingsTimeDayOfWeekTimeDayOfYearTimeGMTTimeGMTOffsetTimeHourTimeLocalTimeMinuteTimeMonthTimeSecondsTimeToStructTimeTradeServerTimeYearYear
Global variables 11
GlobalVariableCheckGlobalVariableDelGlobalVariableGetGlobalVariableNameGlobalVariablesDeleteAllGlobalVariableSetGlobalVariableSetOnConditionGlobalVariablesFlushGlobalVariablesTotalGlobalVariableTempGlobalVariableTime
Math 55
acosasinatanatan2ceilcoscoshexpfabsfloorfmaxfminfmodloglog10MathAbsMathArccosMathArccoshMathArcsinMathArcsinhMathArctanMathArctan2MathArctanhMathCeilMathCosMathCoshMathExpMathExpm1MathFloorMathIsValidNumberMathLogMathLog10MathLog1pMathMaxMathMinMathModMathPowMathRandMathRoundMathSinMathSinhMathSqrtMathSrandMathSwapMathTanMathTanhpowrandroundsinsinhsqrtsrandtantanh
MovingAverages.mqh 8
ExponentialMAExponentialMAOnBufferLinearWeightedMALinearWeightedMAOnBufferSimpleMASimpleMAOnBufferSmoothedMASmoothedMAOnBuffer
Objects 17
ObjectCreateObjectDeleteObjectFindObjectGetDoubleObjectGetIntegerObjectGetStringObjectGetTimeByValueObjectGetValueByTimeObjectMoveObjectNameObjectsDeleteAllObjectSetDoubleObjectSetIntegerObjectSetStringObjectsTotalTextGetSizeTextSetFont
Series and symbol 39
BarsCopyCloseCopyHighCopyLowCopyOpenCopyRatesCopyRealVolumeCopySpreadCopyTickVolumeCopyTimeDigitsiBarsiBarShiftiCloseiHighiHighestiLowiLowestiOpeniRealVolumeiSpreadiTickVolumeiTimeiVolumePeriodPeriodSecondsPointRefreshRatesSeriesInfoIntegerSymbolSymbolExistSymbolInfoDoubleSymbolInfoIntegerSymbolInfoStringSymbolInfoTickSymbolIsSynchronizedSymbolNameSymbolSelectSymbolsTotal
Statistics 72
MathAverageDeviationMathBetaMathBinomialCoefficientMathCorrelationPearsonMathCorrelationSpearmanMathCumulativeDistributionBinomialMathCumulativeDistributionCauchyMathCumulativeDistributionExponentialMathCumulativeDistributionLogisticMathCumulativeDistributionLognormalMathCumulativeDistributionNormalMathCumulativeDistributionPoissonMathCumulativeDistributionUniformMathCumulativeDistributionWeibullMathCumulativeMaxMathCumulativeMinMathCumulativeProductMathCumulativeSumMathFactorialMathGammaMathIdenticalMathInterquartileRangeMathKurtosisMathLog2MathLogGammaMathMeanMathMedianMathMomentsMathOrderMathPowIntMathProbabilityDensityBinomialMathProbabilityDensityCauchyMathProbabilityDensityExponentialMathProbabilityDensityLogisticMathProbabilityDensityLognormalMathProbabilityDensityNormalMathProbabilityDensityPoissonMathProbabilityDensityUniformMathProbabilityDensityWeibullMathProductMathQuantileMathQuantileBinomialMathQuantileCauchyMathQuantileExponentialMathQuantileLogisticMathQuantileLognormalMathQuantileNormalMathQuantilePoissonMathQuantileUniformMathQuantileWeibullMathQuickSortAscendingMathQuickSortDescendingMathRandomBinomialMathRandomCauchyMathRandomExponentialMathRandomLogisticMathRandomLognormalMathRandomNormalMathRandomPoissonMathRandomUniformMathRandomWeibullMathRangeMathRankMathReplicateMathReverseMathSequenceMathSkewnessMathStandardDeviationMathSumMathTruncMathUniqueMathVariance
Strings 22
StringAddStringBufferLenStringCompareStringConcatenateStringFillStringFindStringFormatStringGetCharStringGetCharacterStringInitStringLenStringReplaceStringReserveStringSetCharacterStringSetLengthStringSplitStringSubstrStringToLowerStringToUpperStringTrimStringTrimLeftStringTrimRight
Technical indicators 48
BarsCalculatedCopyBufferiACiADiADXiADXWilderiAlligatoriAOiATRiBandsiBandsOnArrayiBearsPoweriBullsPoweriBWMFIiCCIiCCIOnArrayiChaikiniCustomiDEMAiDeMarkeriEnvelopesiEnvelopesOnArrayiForceiFractalsiGatoriIchimokuiMAiMACDiMAOnArrayiMFIiMomentumiMomentumOnArrayIndicatorCreateIndicatorParametersIndicatorReleaseiOBViOsMAiRSIiRSIOnArrayiRVIiSARiStdDeviStdDevOnArrayiStochasticiTEMAiTriXiVolumesiWPR
Education only. Not financial advice.