How forex trading bots work

What happens between a price arriving and an order being placed — the actual mechanism, step by step.

The loop

Every trading bot, however sophisticated, runs the same cycle: receive market data, update indicators, evaluate rules, check risk, place or manage orders, record what happened. Then wait for the next price and do it again.

Everything else is detail about how each of those steps is implemented.

1. Market data

The bot subscribes to a live price feed from the broker, usually as a stream of ticks or completed candles. A candle summarises a period into open, high, low and close.

A well-built bot acts only on *completed* candles. The forming candle can still reverse before it closes, so a bot that acts on it is trading a number that has not settled — and its live behaviour will diverge from any backtest.

2. Indicators and conditions

As each candle closes, the bot recalculates whatever it uses to read the market — moving averages, volatility measures such as ATR, momentum indicators, or structural features like recent highs and lows.

These feed the entry rules. A rule might be as simple as a fast moving average crossing a slow one, or a set of conditions that all have to hold at once.

3. The risk gate

Before any order, a properly built bot checks whether it is allowed to trade at all: is the daily loss limit intact, are there already too many positions open, has the trade count for the day been reached, is the balance above the floor.

This gate is the difference between an automated strategy and an automated disaster. It is the part that keeps a bad day from becoming a blown account, and there should be no code path that bypasses it.

4. Sizing and orders

Position size is calculated from the account balance and the risk per trade, not fixed — so the size adapts as the account grows or shrinks.

The order goes out with its stop loss and take profit attached from the moment it opens. Attaching them afterwards leaves a window where a disconnection means an unprotected position.

5. Managing and recording

The bot then tracks the open position until it closes, at the stop, the target, or on a rule-based exit. It records the outcome and the reason the trade was taken.

That record is what makes the system reviewable. Without it, a losing month is a mystery; with it, you can see which setups failed and whether the behaviour matches what was tested.

Why live results differ from backtests

  • Spread and commission, if the backtest did not charge them.
  • Slippage — the price moving between the decision and the fill.
  • Gaps over weekends and news, where the fill is worse than the stop price.
  • Rejected or re-priced orders in fast markets.
  • Strategies fitted so closely to historical data that they describe the past rather than the market.

Common questions

Do trading bots use artificial intelligence?

Most do not. The large majority are rule-based systems executing conditions written by a person. Some use statistical optimisation to tune their parameters. Genuine machine learning models are far less common than the marketing suggests.

How fast do trading bots trade?

It depends entirely on the strategy. A bot on hourly candles might trade a few times a week; one on one-minute candles many times a day. Faster is not better — more trades means more spread and commission paid.

What happens if the bot loses connection?

A well-built one reconnects automatically and reconciles its open positions with the broker on return. This is also why stops belong on the order at the broker rather than held in the bot's memory.

Trading carries risk and you can lose money. Nothing on this page is financial advice. Past performance does not indicate future results.