TradingProgress
Toggle menu

Tier 4 · Strategist · Module 4.3

Algorithmic trading concepts (signal generation, execution logic)

The building blocks of any automated trading system — data, signal generation, filters, risk sizing, execution logic, state, and monitoring — and how to turn written rules into a system you can trust.

Lesson 1 of 3 · 6 min read

"Algorithmic trading" sounds like the domain of banks with rooms full of engineers. At its core, though, an algorithm is simply your written strategy (see Entry, stop, and target rules) expressed so precisely that a computer can follow it. Understanding the parts of an automated system helps you whether you build one, buy one, or just want to trade your own rules more consistently.

What you'll learn

  • The components of an automated trading system
  • Signal generation and filters: from rules to signals
  • The risk layer: position sizing and limits in code
  • Execution logic: order types, slippage, retries, and partial fills
  • State, logging, and monitoring — what separates a script from a system

1. The components

A trading system can be broken into layers:

LayerQuestion it answers
DataWhat prices (and other data) do we see, and when?
Signal generationDo the rules say "buy", "sell", or "nothing"?
FiltersAre conditions suitable — session, news, spread, volatility?
Risk layerHow big, and does it fit within all limits?
ExecutionHow exactly do we place, modify, and close orders?
StateWhat positions and orders exist right now?
Monitoring and loggingWhat happened, and is everything still working?

Weakness in any layer can make a profitable strategy lose money.

2. Signal generation

A signal is the output of your rules at a point in time. It must be fully specified — the same data must always produce the same signal.

(Illustrative rule set, written as logic.)

  • Bar-close evaluation: evaluate only when an H1 candle closes (to avoid acting on candles that are still forming — see Intro to automated backtesting concepts).
  • Trend condition: close is above the 200-period SMA, and the SMA is rising.
  • Setup condition: the low touched the 50-period EMA and the close finished back above it.
  • Signal: if both are true and no position is open → LONG signal.

Filters

Filters don't create signals; they block them in unsuitable conditions:

  • Time filter: only between 07:00 and 17:00 GMT
  • News filter: no new entries within 30 minutes of high-impact releases
  • Spread filter: skip if the current spread is more than twice its typical level
  • Volatility filter: skip if ATR is outside a normal range

3. The risk layer

The risk layer converts a signal into a position size and checks every limit before anything is sent:

  1. Calculate the stop distance (for example 1.5 × ATR).
  2. Size the position from risk per trade and pip value (see Pips, lots, and pip value across pairs).
  3. Check limits: total open risk, risk per theme, daily loss limit, maximum trades per day.
  4. If any check fails, no order is sent.

The risk layer should be able to override any signal. A system whose signals can bypass risk limits is not a system — it's an accident waiting to happen.

4. Execution logic

Turning a decision into a filled order is harder than it sounds:

IssueWhat the system must handle
Order typeMarket, limit, or stop — and why (see Market, limit, stop, stop-limit orders)
SlippageThe maximum acceptable deviation; what to do if exceeded
RejectionsRequotes, "off quotes", insufficient margin, market closed
Partial fillsRecalculating stops and targets on the size actually filled
Stop and target placementAttach them immediately, and confirm the broker accepted them
RetriesWhen to retry, how many times, and when to give up

Worked example: why execution matters

(Illustrative.) A short-term strategy wins 50% of the time, with an average win of 12 pips and an average loss of 10 pips. The backtest assumes every order fills exactly at the bar's close. Live, spread and slippage make each entry and each exit about 0.4 pips worse.

  • Backtest expectancy: 0.5 × 12 − 0.5 × 10 = +1.0 pip per trade
  • Live cost per trade: 0.4 (entry) + 0.4 (exit) = 0.8 pips
  • Live expectancy: 1.0 − 0.8 = +0.2 pip per trade — only a fifth of the tested edge

Short-term systems live and die by execution quality.

5. State, logging, and monitoring

  • State: the system must always know what it holds. After a restart or disconnection, it should reconcile with the broker rather than assuming.
  • Logging: record every signal, decision, order, fill, and error with timestamps. Without logs, you can't diagnose problems.
  • Monitoring: alerts for disconnections, unexpected positions, repeated rejections, or losses beyond limits — and a kill switch that closes everything and stops trading.

Common beginner mistakes

  • Evaluating signals on unfinished candles.
  • No risk layer — or one that signals can bypass.
  • Assuming every order fills at the expected price.
  • No logging, making problems impossible to diagnose.
  • No kill switch or monitoring.

Key terms

TermMeaning
SignalThe output of trading rules: buy, sell, or nothing
FilterA condition that blocks signals in unsuitable conditions
Risk layerThe component that sizes positions and enforces limits
Execution logicHow orders are placed, managed, and confirmed
StateThe system's record of current positions and orders
ReconciliationChecking the system's state against the broker's records
Kill switchA control that immediately stops trading and closes positions

Practice

  1. Take your written strategy and split it into the seven layers above. Which layers are fully specified, and which are vague?
  2. List every filter you'd need (time, news, spread, volatility) with exact values.
  3. Write the risk-layer checks in order, ending with "if any fail, send nothing".
  4. List five execution failures that could happen, and what your system should do in each case.

Quick recap

  • An automated system has data, signal, filter, risk, execution, state, and monitoring layers.
  • Signals must be fully specified and evaluated on closed bars.
  • The risk layer must be able to veto any signal.
  • Execution handles slippage, rejections, partial fills, and stop placement.
  • State, logs, monitoring, and a kill switch separate a script from a system.

Educational content only — not financial advice. Trading involves substantial risk of loss. Practise on a demo account before risking real money.

Back to Strategist

Loading