Algorithmic Trading

Algorithmic trading is the execution of orders by a pre-defined rule set rather than by manual entry. A program monitors market data and, when its stated conditions are met, sends, modifies or closes an order. The rules are fixed in advance and the software applies them without discretion.

What an algorithm has to specify

A rule that can be executed automatically has to be complete. Four parts are unavoidable:

  • Entry condition. The exact, testable state that triggers an order — a price level, an indicator value, a time, or a combination. "When the market looks weak" cannot be coded; "when the last close is below the 50-period average" can.
  • Position size. How many units the order is for, and how that number is derived from account equity and the distance to the exit. A size rule is part of the algorithm, not an afterthought.
  • Exit condition. Both exits: the protective level and the closing level, with the rule for moving them once the position is open.
  • Failure handling. What happens when the order is rejected, when the platform disconnects, when the position is already open, or when data stops arriving. Without this branch the program keeps sending orders into a state it does not understand.

How it differs from copy trading and from an expert advisor

Copy trading mirrors another account's transactions. The logic sits with the person being copied and is usually not disclosed, so the follower cannot inspect the entry condition or the sizing rule; what is automated is the replication, not the decision. An expert advisor on MT4 is one implementation of algorithmic trading — a program written in MQL that runs inside the terminal and places orders through it. Every EA is an algorithm; not every algorithm runs as an EA, since the same rules can execute through an API or on a server outside the platform. Automation changes who presses the button. It does not make a rule correct, and it does not make automated execution superior to manual execution — the result depends entirely on the rule and on how it fills.

Reference: contract sizes, pip values and margin figures used by an MT4-based rule are set out in trade calculations for MT4.

What breaks in live execution

A rule that works on paper meets four frictions in the market:

  • Latency. Time passes between the signal, the order leaving the machine and the order reaching the venue. In fast conditions the price at arrival differs from the price that triggered the rule.
  • Requotes and rejections. An order can come back unfilled. If the algorithm has no branch for this, it either abandons the trade or resubmits into a worse market.
  • Slippage. Market and stop orders fill at the next available price, not the requested one. Around releases and at session boundaries that gap widens, and it works against the position in both directions.
  • Changing spreads and swaps. A spread assumed to be fixed is not. Overnight financing accrues for every day a position is held, and both costs must be inside the rule's arithmetic, not outside it.

These frictions are the reason a rule is tested before it is run. Backtesting covers the conditions under which that test means anything.

Related terms

Udělejte svůj první krok na trhu

Otevřete si obchodní účet během několika minut a začněte budovat svou strategii s výkonnými obchodními nástroji.

66.7% účtů retailových investorů prodělává peníze při obchodování CFD s tímto poskytovatelem. Zhodnoťte, zda vám tato úroveň rizika vyhovuje. Číst více