Strategy guide

Trading bot algorithms: the main types and how each one fails

Trading bot algorithms are fixed rule sets that tell a program when to enter, when to exit and how large a position to open. Most fall into a few families: trend following, mean reversion, breakout, grid, martingale-style sizing, arbitrage and scalping. Each family suits some market conditions and hurts in others, so test each one before use.

Trading forex and CFDs involves substantial risk of loss. Automation applies rules; it does not remove trading risk. Read our risk disclosure.

Key takeaways

What trading bot algorithms do

A trading bot is a program that runs on price data and sends orders to a broker. Its algorithm is the set of rules that turns that data into decisions. MetaQuotes describes these programs as robots that analyse prices using preset algorithms, and calls them Expert Advisors (EAs) in MetaTrader 5.

entry rule: a condition on price or indicator valuessize = risk amount ÷ (stop distance × value per unit)exit: stop, target, or a rule-based close

Every algorithm needs all three parts. An entry rule with no sizing rule and no exit is not a complete strategy, and a backtest of it says little about live behaviour.

The main families compared

Common trading bot algorithm families. Failure modes are typical, not exhaustive.
FamilyDecision ruleTypical inputsMain failure mode
Trend followingEnter with a move when a fast average crosses a slower oneMoving averages, price channels, trend-strength readingsRepeated whipsaws in sideways markets; late entries after a move is largely done
Mean reversionBuy after price stretches far below its average, sell after it stretches far aboveDistance from a moving average, RSI bands, standard-deviation bandsA trend that keeps going, so the stretched price keeps stretching
BreakoutEnter when price closes beyond a range high or lowRange length, consolidation tests, time windowsFalse breaks that return inside the range
GridPlace buy or sell orders at fixed price steps around a levelGrid step, number of levels, lot per level, range limitsA one-way trend fills levels with no exit, so exposure grows
Martingale-style sizingIncrease size after each loss to recover earlier lossesMultiplier, number of steps, maximum lot capA losing streak in which size grows faster than the account. Severe risk.
Arbitrage and latencyAct on small price differences or quote delaysQuote timing, spread, execution speedSpread, slippage and commission can exceed the difference; broker rules may prohibit it
ScalpingTake many small moves with tight stops and targetsShort timeframes, spread filter, session filterSpread and commission dominate small targets; slippage in fast markets

Rules shown are simplified descriptions of each family, not trading instructions.

Four families in more detail

Four cards for trend following, mean reversion, breakout and grid. Each card shows a small chart glyph, the decision rule in one line, and an orange line naming the condition where that family fails.
Concept diagram, not an app screenshot.

Trend following

The rule assumes that a move in one direction tends to continue for a while. Results depend heavily on how the trend is defined. A bot that waits for confirmation enters later and gives back more of the move. Sideways markets are a common source of losses for this family.

Mean reversion

The rule assumes that price returns toward an average after a large stretch. The main risk is that a stretch becomes a trend. A stop-loss placed on a stretched price is what turns a drawdown into a large loss, so the stop logic needs as much testing as the entry.

Breakout

The rule assumes that a range boundary, once broken, leads to a move. Many breaks fail, and the rule has no way to tell a real break from a false one in advance. Filters on range size and volatility are common, and each one adds parameters to tune. The breakout Expert Advisors guide covers the entry rules in detail.

Grid

A grid bot opens positions at set intervals, so it accumulates exposure as price moves against it. Its results are closely tied to the range it is built for. Without a hard exposure cap, a trend outside that range can produce losses that are far larger than the trades suggest. The grid and martingale risk guide works through the exposure and margin arithmetic.

Example (illustrative numbers, not a result): a martingale-style scheme starts at 0.01 lots and doubles after each loss. After seven straight losses the next order is 1.28 lots, and the total open size across the sequence is 1.27 lots. A cap on steps or lot size is the minimum safeguard to check.

Arbitrage, latency and scalping

Arbitrage and latency strategies try to profit from price differences or from delays in quotes. They depend on fast, consistent execution, and most retail setups do not have that. Spread, slippage and commission can absorb the whole difference, and broker terms may prohibit the approach.

Scalping uses short holding times and small targets. The spread and commission are a larger share of each trade, so a scalping bot needs a spread filter and an execution check before any test result is trusted. Some firms also restrict short-holding strategies, so read the rules first. See Is an EA allowed in trading?.

Combining filters with an algorithm

Filters decide when the main rule is allowed to act. They are usually added to a family rather than used alone:

Each filter adds at least one parameter. The more parameters are tuned to past data, the more a good backtest describes that past sample and not future prices. Keep the filter set small and write down why each filter exists.

How to test each algorithm family

  1. Write the rule in plain words: entry, exit, size, and the largest loss you accept per trade and per day.
  2. Test on history in the Strategy Tester. Use real ticks where your broker’s history supports it, and test more than one period.
  3. Check how the result changes with the date range and with the symbol. A rule that only works on one slice is not yet tested.
  4. Run the bot on a demo account as a forward test, and record every trade in a journal.
  5. Compare forward results with the backtest only as a consistency check. Neither one forecasts live results.

The Strategy Tester settings and modelling options vary by MT5 build, so confirm the names in your own terminal. The expert advisor tester guide walks through the settings, and how to verify a trading bot explains what the evidence does and does not show.

Backtests and demo results are not proof of live results.

Where YO4X fits

YO4X is a Windows desktop workspace for supported MetaTrader 5 strategies, bot configuration and trading journals. It runs on 64-bit Windows 10 and Windows 11. The current desktop workflow is gated to supported MT5 demo accounts, and live-money trading is not released.

YO4X does not execute EX5 files or arbitrary uploaded code. Use only bots you wrote, bought or licensed. Keep a record of each test and each demo trade in the trading journal, and see the download page for the Windows app.

Frequently asked questions

What are the main trading bot algorithms?

The common families are trend following, mean reversion, breakout, grid, martingale-style sizing, arbitrage and latency, and scalping. Each one has a different decision rule and a different main failure mode. Many working bots combine a family with filters.

Which trading bot algorithm is the best?

No family is best in every market, and this guide does not claim that any one of them is superior. Each one depends on market behaviour that can change. The useful question is which conditions a rule was designed for, and what happens when they stop holding.

Can a trading bot algorithm predict the market?

No. An algorithm applies fixed rules to price data and sends orders when those rules are met. A backtest shows how those rules performed on a past sample, and a demo test shows short-term behaviour on a simulated account. Neither result is a forecast.

Is martingale-style sizing safe?

It is not safe. Increasing size after each loss can make a normal losing streak very costly, because the size grows faster than the account can absorb. If you test any sizing scheme of this kind, set a hard cap on size and total exposure first.

Do brokers or prop firms allow every bot type?

Not necessarily. Brokers and firms set their own rules, and some restrict latency-sensitive, scalping or copying approaches. Read the broker agreement or the firm rules before running a bot on any account, and ask support in writing if the rules are unclear.

Keep reading

Sources: Algorithmic Trading, Trading Robots - MetaTrader 5 Help · Strategy Testing - Algorithmic Trading, Trading Robots - MetaTrader 5 Help

Trading forex and CFDs involves substantial risk of loss. Past performance and backtests do not guarantee future results. Read our risk disclosure before you trade.