metatrader 5

CopyBuffer in MQL5: Read Closed Bars Without Reversing Your Signals

CopyBuffer in MQL5: Read Closed Bars Without Reversing Your Signals

Technical revision: 1 October 2026 · Educational materialOn this pageFirst choose the barsUse a numerical test before using a chartRequire a complete and valid readDistinguish physical storage from series indexingA short verification sequenceA common MQL5 fault is to read two indicator values correctly, then interpret their array positions backward. Another is to evaluate an unfinished candle while describing the rule as a closed-bar signal. Both faults can change an EA's entries without producing a compiler error. First choose the bars Shift 0 refers to the current, unfinished bar. Shift 1 is the last closed bar; shift 2 is the closed…
Read More
How to Backtest an MT5 Expert Advisor: A Reproducible Validation Checklist

How to Backtest an MT5 Expert Advisor: A Reproducible Validation Checklist

Technical revision: 1 October 2026 · Educational materialOn this page1. Verify behavior before evaluating returns2. Save a complete test record3. Reserve chronological evaluation periods4. Measure the effect of searching5. Test operational and market stress separately6. State what the evidence supportsAn MT5 tester report is the output of a particular program, dataset and configuration. It is useful only when those inputs are recorded and the result is interpreted within their limits. This checklist helps you prepare a reproducible experiment; it does not certify a strategy as profitable. 1. Verify behavior before evaluating returns Compile the EA in MetaEditor and resolve errors.…
Read More
MT5 Order Errors 10014, 10016 and 10030: Volume, Stops and Filling

MT5 Order Errors 10014, 10016 and 10030: Volume, Stops and Filling

Technical revision: 1 October 2026 · Educational materialOn this pageRead the server result10014: invalid volume10016: invalid stops10030: invalid fillingRun a read-only trade diagnosticUse a repeatable debugging sequenceWhen a trade request fails, inspect the server return code and the request values together. A generic “order failed” message hides whether the issue is volume, protective prices, execution policy or something else. Blind retries can create a new problem if the original response was uncertain. Read the server result CTrade method returns and ResultRetcode describe different layers. Log the method result, numeric server code, its description, symbol, requested volume and prices. A request…
Read More
Trailing Stops in MQL5: Filter Positions and Respect Broker Constraints

Trailing Stops in MQL5: Filter Positions and Respect Broker Constraints

Technical revision: 1 October 2026 · Educational materialOn this pageManage only the positions you ownDefine activation, distance and minimum improvementUse the downloadable managerCheck constraints before modifyingCompare exits, not selected success storiesA trailing stop changes the requested exit level after price moves in favor of a position. It changes the distribution of exits; it does not prove that a strategy has an edge. Compare it with a fixed-stop baseline using the same entries, costs and validation periods. Manage only the positions you own Iterating over all account positions while using the chart symbol's prices can modify an unrelated trade. The example…
Read More
Risk Management in MQL5: Position Sizing and Broker-Valid Stops

Risk Management in MQL5: Position Sizing and Broker-Valid Stops

Technical revision: 1 October 2026 · Educational materialOn this pageEstimate entry-to-stop loss in account currencyRound down and reject oversize minimumsRound prices on the tick gridAccount risk is broader than one stopPosition sizing should translate an explicit loss estimate into a broker-valid volume. It should also know when no valid order fits the budget. A stop defines a requested exit condition; it cannot guarantee the realized loss when execution gaps or costs differ from the estimate. Estimate entry-to-stop loss in account currency Using a fixed pip value can fail across symbols, contract types and account currencies. The helper uses OrderCalcProfit at…
Read More
Your First MQL5 Expert Advisor: Closed-Bar Signals and Demo Orders

Your First MQL5 Expert Advisor: Closed-Bar Signals and Demo Orders

Technical revision: 1 October 2026 · Educational materialOn this pageMake the rules explicitRead the execution policyEstimate risk without forcing the minimum lotDo not confuse a request with a fillRun a behavior test before a performance testThis tutorial turns a simple moving-average crossing into a complete educational EA. Follow it at your own pace: installation, compilation and verification take longer when your broker has different symbol specifications. The source is a learning exercise, with no published profitability claim. Make the rules explicit A buy signal occurs when the fast EMA was at or below the slow EMA on bar 2 and…
Read More