Mon Oct 26 2026

In the previous article of the TradeTogether Automation Trading Series, we explored what automated trading is, how trading bots work, and how manual trading differs from automated trading.
Follow the series in order: Read the Forex Automated Trading Masterclass to follow our automation articles in a structured sequence, starting with the fundamentals and progressing towards strategy design, backtesting, risk management, and automated system development.
Now comes the next important question: How do you turn a trading strategy into something a computer can execute?
Imagine a Forex trader who has spent months studying price action. The trader understands market structure, identifies support and resistance, recognizes Fair Value Gaps (FVGs), and looks for confirmation before entering a trade. The process might work reasonably well when performed manually.
But when the trader tries to automate it, a problem appears.
What exactly qualifies as a valid support level? How far can price move beyond a level before a breakout is considered invalid? Which candle confirms the entry? Where should the stop-loss be placed? What happens if the spread suddenly increases?
A human trader might answer these questions through experience and judgment. A computer needs instructions that can be interpreted consistently.
This is the foundation of automated strategy development. Before writing code or building an Expert Advisor (EA), a trader must convert the trading idea into a clear set of rules.
In this chapter, we will examine how to define trading conditions, structure entry and exit rules, incorporate risk management, handle situations in which no trade should occur, and turn a Forex strategy into a specification that can eventually be programmed and tested.
Not every trading strategy is equally easy to automate. The main difference is how precisely its decisions can be defined.
An objective rule has a clear condition that can be evaluated.
For example:
A subjective instruction is less precise.
For example:
These instructions may make sense to an experienced discretionary trader, but they leave room for interpretation.
| Trading instruction | Suitable for direct automation? | What is needed? |
|---|---|---|
| Buy when the 20 EMA crosses above the 50 EMA | Generally yes | Define the timeframe and crossover calculation |
| Enter after a candle closes above resistance | Potentially | Define how resistance is identified and which candle close qualifies |
| Buy when the trend looks strong | Not yet | Establish measurable conditions for trend strength |
| Avoid trading when volatility is too high | Not yet | Define how volatility is measured and the permitted range |
| Risk 1% of account equity per trade | Generally yes | Define the risk calculation, stop distance, and instrument specifications |
The important lesson is that a trading concept does not necessarily need to be simple to automate. It needs to be defined precisely enough for the computer to evaluate it.
Suppose a trader wants to automate a breakout strategy.
The instruction is:
Buy when price breaks resistance.
That sounds straightforward, but several questions remain:
Different answers produce different trading systems, even though they all begin with the same idea.
Before automation, these decisions must be made deliberately. Otherwise, the programmer may unknowingly make trading decisions on the trader's behalf.
A complete trading strategy contains more than an entry signal. It needs rules for the market being traded, the conditions required for entry, the management of open positions and the circumstances in which trading should stop.
Start by specifying what the system will trade.
For example:
A strategy that works on EURUSD may not behave the same way on gold. The instruments have different price characteristics, trading costs and volatility patterns.
Even when the same logic is applied, the system may need instrument-specific settings. These should be tested rather than assumed to work equally well across every market.
A strategy must specify which timeframe is used for each decision.
For example, a trader might use the one-hour chart to identify the broader trend and the five-minute chart to find an entry.
The rules should clarify:
This last question is particularly important. A condition that appears during a candle may disappear before the candle closes. If the strategy requires candle-close confirmation, the automated system must wait for that confirmation.
Some strategies work differently depending on the market environment.
A trend-following strategy may be designed for directional price movement, while a range-based strategy may look for opportunities between established boundaries.
The strategy should specify any market filters it requires, such as:
These filters should have a clear purpose. Adding more conditions does not automatically improve a strategy; unnecessary filters can eliminate valid trades or make the system overly dependent on historical conditions.
Entry rules explain exactly when the system is permitted to open a position.
Consider this general instruction:
Buy after a bullish breakout.
To automate it, the trader might define the following conditions:
Resistance is identified using a specified method.
A candle closes above that level.
The candle meets a predefined confirmation condition.
The spread is within the permitted limit.
No conflicting position or trade restriction prevents entry.
These conditions turn a broad trading idea into a sequence of decisions.
They do not prove that the breakout will succeed. They simply define what the system must observe before entering.
A strategy is incomplete if it explains only how to enter.
It must also define what happens after entry.
Stop-loss rules might use:
Exit rules might use a fixed target, a risk-reward ratio, a trailing stop, an opposite signal or a time-based condition.
The appropriate method depends on the strategy. A stop-loss should not be selected merely because a particular distance is easy to program.
The system must also define what happens when a trade is already open and another signal appears. Should the new signal be ignored, should the existing trade be closed, or should additional positions be permitted? Each choice changes the system's exposure.
Risk management should be part of the original specification, not something added after the strategy has been programmed.
Suppose a trader has a hypothetical account equity of $10,000 and chooses to risk 0.5% per trade.
The planned monetary risk is:
$10,000 × 0.05 = $500
The system can then calculate the position size based on the stop-loss distance, the instrument's contract specifications and the value of a price movement.
For Forex pairs, the pip value depends on the currency pair, position size and account currency. For gold, the calculation depends on the broker's contract specifications and the price movement being measured.
The intended risk is not a guarantee of the final loss. Gaps, slippage and execution conditions can cause the actual loss to differ from the planned amount.

One of the most useful ways to prepare a strategy for automation is to separate the original idea from the exact instructions required to execute it.
Consider the following progression. Trading idea: Buy a bullish breakout.
Trading idea: Buy a bullish breakout.
Trading rule: Enter after a candle closes above a defined resistance level.
Additional conditions: The spread must be acceptable, the trading session must be permitted, and the account must remain within its risk limits.
Trade management: Calculate position size, place the stop-loss and apply the defined exit rule.
The result is a decision process that can be expressed in an algorithm.
An algorithm is simply a sequence of instructions used to solve a problem or perform a task. In automated trading, it describes how the system moves from market information to a trading decision and then to execution.

Imagine a trader wants to build a simple EURUSD trend-following system.
The initial idea is to buy when the shorter-term trend turns bullish while the broader trend remains upward.
The trader could turn that idea into the following specification:
| Component | Example rule |
|---|---|
| Instrument | EURUSD |
| Broader trend | Price is above the 200 EMA |
| Entry signal | The 20 EMA crosses above the 50 EMA |
| Confirmation | The signal candle must close |
| Position sizing | Calculate volume using a predefined risk percentage |
| Stop-loss | Use a defined technical level |
| Take-profit | Use a predefined exit rule, such as a 1:2 risk-reward target |
| Trade limit | Allow no more than one open position |
| No-trade condition | Do not enter if the spread exceeds the specified maximum |
This table is an illustration of how to document rules, not a recommendation to trade this particular setup.
The next step would be to define any remaining details, such as how the moving averages are calculated, how the crossover is detected, how the stop-loss distance determines position size and what happens if an order is rejected.
Only then is the strategy specification sufficiently detailed to begin implementation and testing.
Traders naturally focus on finding entries. But an automated strategy also needs to know when it must remain inactive.
These are often called no-trade conditions or trading filters.
Examples include:
Some systems may also include restrictions around scheduled economic releases. Such a filter must be clearly defined and supported by an appropriate source of event data if it is to operate automatically.
A no-trade condition is not wasted activity. It is part of the strategy's decision-making process.
For example, a valid technical signal may appear during a period of unusually wide spreads. A system with no spread filter might enter anyway, while a system with a predefined spread limit would wait.
The filter does not guarantee a better result in every situation, but it makes the strategy's behavior explicit.
Many Forex traders use concepts that require interpretation. These can sometimes be automated, but the underlying definitions need to be made clear.
Instead of instructing a bot to identify a strong trend, define the conditions used to classify the trend.
Possible inputs include moving-average relationships, swing highs and lows, or other measurable criteria.
Each method captures a different aspect of price behavior, so the choice should match the strategy's logic.
A trader may identify a resistance zone visually, but the system needs a method for finding it.
For example, the specification could define a swing high using a particular number of candles on either side. It would also need to explain whether the level is treated as a single price or a zone and how long it remains valid.
There is no single definition that all traders use. Different definitions can produce different results.
A breakout can be defined using a candle close, a minimum distance beyond a level or an additional confirmation condition.
The system must also determine whether a brief move beyond the level counts as a breakout or whether the candle must finish beyond it.
These choices affect the timing and frequency of entries.
Concepts such as liquidity, order blocks and Fair Value Gaps can be more challenging because traders may interpret them differently.
For an order block, the specification might need to define which candle qualifies, what price range is used, what confirms the associated move and what invalidates the zone.
For an FVG, it might need to define the candle relationship, how the gap is measured and whether a partial or complete fill changes its status.
The aim is not to claim that one definition is universally correct. It is to ensure that the chosen definition is consistent enough for the system to apply and for the trader to evaluate.
Several problems can emerge before programming even begins.
Instructions such as “buy strong momentum” or “avoid bad setups” leave too much room for interpretation. Define the conditions that determine what qualifies.
More conditions can make a strategy look sophisticated without necessarily improving its underlying edge. Every filter should have a clear rationale and be evaluated through testing.
A losing trade does not automatically mean that a strategy is defective. Continually changing the rules after a small number of outcomes can make it difficult to evaluate the original approach objectively.
Spread, commissions and slippage can materially affect a strategy, particularly when it trades frequently or targets small price movements. These costs should be considered during testing.
Position sizing, exposure limits and loss restrictions need to be part of the design. A strategy should not be considered ready merely because its entry signal has been automated.
Before beginning development, prepare a written strategy specification. This document becomes the reference for programming, testing and later troubleshooting.
It should cover:
If a developer cannot implement a rule without asking what it means, the specification probably needs more detail.
This does not mean every market decision can be reduced to a perfect formula. Some strategies are inherently discretionary, and some concepts remain difficult to quantify. In those cases, partial automation may be more appropriate than attempting to automate every decision.
The central lesson of this chapter is that a trading strategy must be clearly defined before it can be reliably automated.
An entry signal is only one part of the process. The trader must also specify the market conditions, timeframe, stop-loss, exit logic, position sizing, risk limits and situations in which the system should not trade.
These rules connect directly with the broader concepts covered throughout Forex education. Market structure and trend analysis can help define context; support and resistance can provide measurable reference levels; volatility can inform filters and stop placement; and risk management determines how much capital is exposed.
The definitions themselves are not guarantees of success. Their purpose is to make the strategy consistent enough to implement and test.
Once the rules are documented, the next stage is to translate them into software and examine whether the resulting system behaves as intended. That leads naturally to the next chapter: how automated trading systems and Expert Advisors are built.
Start by documenting the instrument, timeframe, entry conditions, exit rules, position sizing and risk limits. Define every condition clearly enough that a computer can evaluate it without subjective interpretation. Then translate the specification into code and test whether the system follows the intended rules.
No. Strategies based on clearly defined, measurable conditions are generally easier to automate. Strategies that rely heavily on intuition or subjective interpretation may require additional rules or partial automation.
Precise rules help ensure that the system makes decisions consistently. They also make it easier to identify programming errors, backtest the strategy and determine whether its actual behavior matches the original trading idea.
Yes. Position sizing, stop-loss rules, maximum exposure and loss limits should be part of the original design. Risk controls do not eliminate losses, but they help define how the system should manage exposure.
Automated trading begins with clear rules, not code. Define your strategy, specify its risk limits and document when it should not trade before moving to development.
Continue learning through the Forex Automated Trading Masterclass to follow the series from the fundamentals to building and testing automated trading systems.

Written by
Trade Together Research is a professional market analysis team providing forex, gold, and crypto trading insights, technical analysis, and educational guides.. Learn more about our research team on the About page.