A first algorithmic project can record signals, calculate position size or check exposure without placing a trade. Start with one operation whose result you can explain and verify. Define the information, rule and program behaviour before granting order permissions; automation does not establish a profitable strategy.

What algo trading is and definitely is not

Separate signal selection, execution of an existing decision, position management and reporting. A program slicing an existing order does not have the same purpose as a robot selecting entries. BIS’s 2020 report on FX execution algorithms discusses market structure, execution and associated risks; it is not evidence that a particular retail trading robot earns a profit. Its abbreviation EA means execution algorithm, whereas MetaTrader uses EA for Expert Advisor.

Specify the instrument, data source, operating times, decision timestamp, entry and exit rules, size, exposure limit and behaviour when a position already exists. Automation retains human decisions about those inputs and supervision. It may prevent one manual mistake while introducing another, such as a duplicate request after a restart. Check program correctness separately from the rule’s economic result.

Choose tools for the task

An alert may be enough for a notification task. Native MT5 Alerts accepts price, last-deal volume and time comparisons; it is not an arbitrary moving-average-and-ATR editor. An indicator or EA may be needed for custom logic. MQL5 works inside MT5, while Python may analyse data or use an appropriate documented connection. There is no required sequence from alerts to MQL5, Python and FIX.

Choose the environment that fits the account, data and operation. Do not assume a standard line count, build time, execution latency or API access on every broker product. The guide to MQL5 expert advisor basics explains the platform’s program behaviour; Forex backtesting in Python covers a separate research workflow. Reimplementing the same idea in both is optional.

The third average input cannot be guessed

The requested number of records is part of the rule. Two valid prices cannot establish a three-price average.

Scroll sideways to see the full diagram

The third average input cannot be guessedOur rule compares the last completed price, 102, with the average of exactly three completed prices. Only the two newer values, 100 and 102, are known; the older x is missing. If x were 98, the average would be 100 and 102 > 100. If x were 106, the average would be 102.666... and 102 would not be greater. These are alternative completions of missing past history, not future prices. Both averages use one linear axis from 99 to 104, with a vertical marker at 102 and different decisions. Without the third record, the program suspends evaluation rather than substitutes zero.MISSING DATA CHANGES THE DECISIONOur rule: last price > 3-price meanx = ?100102The older price is unknown.Two possible historical completions:x = 98: (98 + 100 + 102) /3 = 100x = 106: (106 + 100 + 102) /3 ≈ 102.667Last: 1029910499104x = 98x = 106Without x: do not evaluate the 3-price rule.

Assumptions: Hypothetical prices for one instrument and interval. All records are completed historical bars; x is an unknown older price, not a future price. Equal weights of 1/3, with no rounding before comparison. Neither alternative is claimed to be market data.

Exactly three closing prices are required: x, 100 and 102, oldest to newest. Only 100 and 102 are known. The invented alternatives x = 98 and x = 106 give means of 100 and 308 /3 ≈ 102.667, respectively. The condition last price > mean has different results.

Averaging the two known prices to obtain 101 changes the rule. Substituting zero creates a fictitious third input. The program must record incomplete data and issue no decision. If retrieval later succeeds, check that it refers to the same intended bars.

MQL5 — record count returned by CopyRates describes copied records, errors and partially available data. This counterexample concerns completeness, not indexing direction or array order.

The same last price produces different decisions depending on the missing history.

Skills and the language choice

Useful skills include programming, data handling, risk sizing and statistical reasoning. A short equity curve is evidence about that sample, not proof of future profitability. Plan a validation process with representative data, out-of-sample evaluation and demo execution checks. MQL5 connects through the MT5 terminal, while Python can use that terminal or other documented interfaces. End-to-end latency depends on code, hosting, network and broker execution; it is not guaranteed to be single-digit milliseconds.

An illustrative example — first strategy from concept to backtest

For a hypothetical EUR/USD H1 crossover, define the EMA, SMA and ATR calculation, signal timing, stop and target precisely. Compare manual and automated decisions on the same data and dates first. A five-year automated test need not match a six-month manual sample: regimes and feeds differ. Reconcile same-period discrepancies, model costs and then evaluate the frozen rules on separate data.

An offline specification might use EMA 21, SMA 55 and an ATR-based distance chosen for the exercise. State whether decisions use completed H1 bars and when the program may evaluate them. Initially log the signal rather than submit an order. Test one signal, no signal, a bar change, missing history and an existing position. A missing input is not a valid “no entry” result.

As a separate hypothetical sizing model, assume USD 10,000 equity, a chosen 0.5% initial price-loss budget, a 25-pip stop distance and EUR/USD pip = 0.0001. With 100,000 EUR per standard lot, the pip value is USD 10 per lot. The budget is USD 50, so volume before costs is 50 ÷ (25 × 10) = 0.20 lots, or EUR 20,000 notional. None of these assumed settings is a universal risk recommendation; notional, margin and initial planned loss are different quantities.

Account for commission and execution assumptions before fitting volume to the contract’s permitted step. An ordinary stop can fill differently during a gap, so the USD 50 plan is not an unconditional maximum loss. Compare identical rules and data, not just similar final profits from different trades.

Keep parameter selection separate from evaluation. A favourable result on the data used to select the rule can reflect selection bias rather than a persistent advantage.

A program can compute a false spread by mixing correct quotes from different times. In a hypothetical stream, t1 has Bid/Ask 1.1000/1.1002 and t2 has 1.1010/1.1012. Both spreads are 2 pips with pip = 0.0001. Combining t1 Ask with t2 Bid instead yields (1.1002 − 1.1010) ÷ 0.0001 = −8 pips. A filter accepting spread < 2.5 would wrongly accept that constructed value; it is not an observed negative market spread.

MQL5 SymbolInfoTick returns current prices and the update time in one MqlTick structure. Check success and calculate the condition from the retained structure’s fields. Add a test that intentionally mixes two changing but individually valid readings. A coherent quote is a data check, not a liquidity or future-fill guarantee.

Test code, data and economic results separately

A project can fail through a bad rule, incorrect code, incomplete data, execution differences or operational problems. Do not infer a fixed two-cause ranking or discount programming errors. After an ambiguous order response, inspect the actual orders, deals and positions before retrying. MQL5 OrderSend returning true alone does not establish a completed fill; inspect its result codes and transaction state. Log the rule version, information timestamp and reason for acting or doing nothing.

A backtest also needs the relevant product data, costs and chronology. Record all attempted variants and distinguish development data from evaluation data; revising the rule after reading an out-of-sample result uses that period for development. The guide to trading edge discovery develops this evaluation. Retain unsuccessful reports and reasons for changes rather than selecting only the best curve.

Win rate, expectancy and profit factor answer different questions. In a hypothetical fixed-R sample of 100 trades with 40 wins of +2R and 60 losses of −1R, the mean is (80 − 60) ÷ 100 = +0.2R before costs. Profit factor is 80 ÷ 60 ≈ 1.33. These are chosen arithmetic inputs, not a tested strategy or evidence that the next sample has those outcomes.

Maintain a cost worksheet for data, hosting, licences and time even if a programming language itself has no licence fee. Provider prices, entitlements and recovery arrangements depend on the chosen setup. Check restart and outage behaviour, using the platforms and tools section for the relevant environment; a VPS does not remove supervision or every failure.

What to do tomorrow

  1. Choose one operation and write a reproducible specification: data, timestamp, rule, result and cases where evaluation must stop. A trustworthy signal log can be a complete first project.
  2. Verify data completeness and quote coherence on small explainable cases. Keep completed bars distinct from the current bar and preserve the timestamp of the inputs used for each decision.
  3. If the project needs orders, add them in a clearly identified demo environment. Test an acknowledged request, a rejection, a restart and an ambiguous response; check actual state before retrying. A calendar deadline does not require progressing to live money.
  4. Freeze the rule for separate evaluation, with product-appropriate costs and data. Compare the same dates and individual decisions. Investigate any material difference rather than declaring a universal percentage tolerance.
  5. Write the pause, restart and update procedure. Disabling local AutoTrading does not close existing positions. Separate accepted server protection from program-managed rules, and check any remote instance independently. Demo observation is not a guarantee of identical live execution.