Artificial intelligenceIntroductory24 min read

Before training a model, build a simple opponent

Build a Forex baseline without machine learning and test whether a model adds value after costs, abstention and simple trading rules.

The first program in this investigation can be described in one sentence: “It does not open a position today either.” It needs no neural network, collection of indicators or explanation of the market. That sounds like an opponent anyone could beat. Yet a strategy that loses money after costs has still failed to beat it under the trading accounting convention we will use here.

The second reference is hardly more impressive: it repeats a constant prediction. The third looks at one condition in the price series. Together they let us ask something more useful than whether artificial intelligence works: which decision does the model improve, and what does that improvement cost?

A baseline is an explicit procedure against which another procedure is compared. It does not have to be profitable or represent the best imaginable trading strategy. Its purpose is to make an experiment interpretable. In this article, we will build that starting point for an introductory Forex investigation before choosing a machine learning algorithm.

Every scenario, quantity and numerical ledger below is a hypothetical teaching example. None represents Atlas research results, live trades or an expected return. The simplified numbers make the calculations easy to check by hand. They do not replace the prices, contract specifications or charges of a particular trading provider.

1. Write the question before naming the algorithm

“I want to predict EUR/USD” leaves almost everything undecided. You might want to forecast direction, estimate the size of a move or choose which entries from an existing strategy deserve further investigation. Each task needs a different reference. A constant prediction is helpful for some statistical questions, but it does not tell you when a trade opens or closes.

Imagine a study that makes a decision after each eligible hourly bar. The system can buy, sell or remain flat. Hypothetical entries use the next executable price specified by the simulator, positions last one hour and overlapping positions are prohibited. This is not a production specification, but it already identifies several things that must stay consistent between competitors.

You also need to define the outcome being predicted. “The next candle closes above its opening price” and “a purchase entered after this decision produces a net profit” are different targets. The second depends on execution prices, position size and charges. Training on the first target and celebrating its accuracy leaves the connection with the second untested.

The basic unit of the study should be an available decision, not a trade selected after its outcome is known. Keep a row for every eligible opportunity, including those that lead to no trade. That makes it possible to check whether a filter improves decisions or merely removes difficult cases from the report.

Part of the decision contract Question to resolve
Opportunity When is a decision allowed?
Information Which inputs are already available then?
Action Buy, sell, hold or abstain?
Size What exposure does each action represent?
Exit Which condition ends the position?
Outcome In which currency, and after which charges, is it measured?

This contract also gives an AI coding assistant a bounded assignment. Instead of asking it to discover the best robot, ask for a function that converts available information into an action under the stated rules. An open-ended prompt leaves more research decisions hidden inside the implementation. A program may run successfully while answering a question you never intended to ask.

A useful starting question could be: “Does a filter using available features improve this entry rule while preserving its exits and position sizes?” We now know what the model is supposed to add. We also know which parts should remain unchanged if we want to attribute a difference to that addition.

2. Staying flat is a complete economic reference

A policy that remains flat produces no trades and no trading profit in our exercise. We assume no interest on idle cash and no fixed account charges. State that convention explicitly. It does not mean holding money is economically costless in every setting; it defines the zero for this particular comparison.

The practical value appears immediately. Suppose a model loses less than an elementary trading rule but still loses money after costs. It has improved on that competitor under the chosen measure. It has not shown that deploying it is preferable to abstaining. Winning a relative comparison does not oblige you to accept its winner.

Abstention also needs an operational meaning. If data are missing, a price is invalid or a required feature cannot be calculated, the program should return an explicit status. “No trade because the data are insufficient” differs from “no trade because the signal fails the condition.” Combining them can hide a model that avoids losses only because it stops functioning during particular hours.

For an introductory Forex study, avoid assuming that buying and holding a currency pair is the universal opponent. A long position in a pair creates exposure to two currencies under particular funding and execution conditions. It can be a useful reference when it answers your question, but it needs to be specified as carefully as any other policy.

The flat line is also an accounting control. If the simulator assigns it commissions from nonexistent trades, price-driven profits or a trading drawdown, something needs investigation. Perhaps the report mixes the account balance with another series. Perhaps zero has been interpreted as a sell order. An apparently trivial opponent can expose a defect that thousands of trades would conceal.

Do not turn that zero into a universal argument against taking risk. It is a reference point. A hedging strategy might deliberately incur a cost to achieve a different objective, but then that objective must be measured. For an investigation seeking trading profit, remaining flat makes the researcher explain why acting is worthwhile.

3. A constant prediction shows what information contributes

Before supplying indicators to a model, build a prediction that ignores them. For classification, you might repeat the most common class observed in the permitted training data or issue the same probabilities for every row. Scikit-learn’s DummyClassifier provides such references: it ignores input features, although several strategies use the training labels.

That distinction matters. “Without machine learning” need not mean “without consulting any data.” Estimating a historical frequency is a simple statistical operation. The useful distinction here is that the reference does not learn a relationship between a collection of features and the outcome. Record which frequency it calculates, which observations it uses and when it may update.

Take a fictional sample of one hundred labels: sixty indicate an upward move and forty a downward move. A predictor that always announces “up” is sixty percent accurate. It has not read a single market feature. If your model has the same accuracy, the claim that it gets six predictions out of ten right does not establish that its indicators provided additional information.

One hundred hypothetical labels include sixty up moves and forty down moves: always predicting up achieves sixty percent accuracy and fifty percent balanced accuracy.
Class frequency can explain an apparently attractive accuracy figure.

To account for both classes, balanced accuracy averages their recall, as defined by balanced_accuracy_score. Our predictor detects every upward move and no downward move. The average of one hundred and zero percent is fifty percent. This clarifies one aspect of classification, but it still does not calculate a trading strategy’s profit.

If the target is a quantity, such as a return, use a reference suited to that task. DummyRegressor can repeat a mean, median, quantile or supplied constant. You could also define a zero predicted return. The choice depends on the question and the error measure, rather than on which reference looks weakest after seeing the results.

These comparisons help distinguish forecasting prices from identifying opportunities. In a series whose changes are small relative to its level, repeating the latest price can produce a small numerical error. That does not establish a profitable decision. Explain whether the error concerns levels, changes, directions or net outcomes, and why that scale is useful for the proposed action.

4. A simple rule must leave no interpretation to the executor

The next opponent uses market information but follows a readable condition. For an educational example, buy when the known closing price exceeds the close four bars earlier, sell when it is lower and abstain when the two are equal. Four is a teaching choice, not a recommended parameter or the outcome of an investigation.

Complete the description with the previous contract: an entry convention, an exit one hour later, constant exposure and no simultaneous positions. You must also decide what missing bars mean. Counting the last four available observations may represent something other than four elapsed hours. The implementation should not silently choose whichever interpretation is easiest.

This rule asks a limited question: does the model add anything beyond a direction based on a recent price change? An opposite-sign rule could provide a reference for a reversal idea. You do not need to begin with a competition among hundreds of indicators. Each additional opponent should answer a recognisable question about what might explain the candidate’s behaviour.

Simple does not mean unselected. A one-line rule chosen from thousands of windows, trading hours and thresholds can embody an extensive search. Preserve its history. Changing four bars to seven after inspecting the results develops a variant even if the code remains short. Code length is a poor measure of how much historical information influenced a choice.

Before calculating a curve, write small implementation cases. When the current close exceeds the earlier close, the expected signal is buy. Equal prices should produce no position. A missing earlier close should return the specified invalid-data status. Then follow one complete trade from that signal to the final accounting entry.

A simple rule makes disagreements easier to locate. You can point to a row, two input values and an expected action. If the discrepancy arises when converting the action into a position, there is no need to debate a neural network’s learning capacity first. The reference has already separated the part of the system that needs attention.

Do not deliberately choose such a weak opponent that defeating it is meaningless. Equally, do not keep improving the reference until it becomes a second research project. A small set of opponents with distinct roles is enough to begin: no activity, no feature information and one elementary price relationship. That variety can explain more than ten near-identical versions of the same indicator.

5. Every opponent goes through the same execution machinery

A comparison becomes difficult to interpret if the model buys at one price and the reference at another without that difference being part of the experiment. Use a common path from action to accounting. Each competitor supplies a decision, and the shared simulator applies the specified position constraints, prices and charges.

This includes signals arriving while a position is already open. Are they ignored, accumulated or used to close the earlier position? If the model can reverse every hour while the reference must wait for its scheduled exit, prediction is not the only difference. That can be a valid comparison of complete systems, but the report needs to identify it as such.

In Forex, check units from the beginning. A movement in pips does not become a monetary profit until quantity, instrument specifications and any required currency conversion are included. The examples below add pips at a constant size to isolate the arithmetic. They are not account percentage returns or statements about the ability to withstand losses.

Spread requires one consistent convention. If you simulate with midpoint prices and deduct an approximate total charge, label that approximation. If you already use executable sides of the market, do not subtract the same differential again. Apply the same care to commissions, slippage and any funding relevant to the holding period.

If you need to review buying and selling prices first, the guide to Forex bid, ask and spread develops that part of the accounting before models are added.

The reference and the model must pay for the decisions they actually generate. Their total costs will not necessarily be equal: the more active policy may pay more. What stays equal is the method used to calculate each charge. Confusing those two requirements can give the more active system an accounting advantage.

Test the shared path using a small fictional ledger that can be reconciled by hand. A purchase, a sale, an abstention and a blocked signal can reveal more during debugging than a chart containing thousands of points. Check that excluded rows remain visible with their reasons rather than disappearing from the record.

Once the accounting behaves as specified, preserve its version throughout the comparison. If a material defect is corrected, recalculate every affected opponent. Comparing a newly corrected candidate with a baseline produced by the defective version measures the infrastructure change as well as the candidate’s contribution.

6. More correct predictions can leave less money

Consider two fictional strategies with one hundred trades each and a simplified total cost of one pip per completed trade. Strategy A wins sixty times: it earns four pips on each winner and loses seven on each loser. Strategy B wins forty-five times: it earns eight pips on a winner and loses four on a loser.

The accounting produces a different ranking from accuracy. A earns two hundred and forty pips on winners and loses two hundred and eighty on losers, leaving a gross loss of forty. After one hundred pips of costs, its result is minus one hundred and forty. B earns three hundred and sixty, loses two hundred and twenty, and retains forty after the same costs.

Hypothetical example A B
Trades 100 100
Winners 60 45
Gain per winner 4 pips 8 pips
Loss per loser 7 pips 4 pips
Gross result −40 pips 140 pips
Total cost 100 pips 100 pips
Net result −140 pips 40 pips
Hypothetical comparison: A wins sixty percent of trades and loses one hundred and forty pips net; B wins forty-five percent and gains forty pips net.
The sizes of gains and losses, together with costs, change the interpretation of accuracy.

This does not prove that a lower win rate is better. It shows that accuracy alone does not determine the economic outcome. The final net result is not sufficient either: we have not described trade order, exposure, elapsed time or uncertainty. B wins only the comparison we have actually calculated under the stated assumptions.

An evaluation sheet should separate three layers. The first concerns prediction: errors, classes and probabilities. The second concerns activity: available decisions, entries, abstentions and exposure. The third concerns economics: gross result, charges, net result and the path of losses. When one layer improves while another deteriorates, preserving both makes the trade-off visible.

For a constant predictor, you might observe acceptable aggregate accuracy and no ability to distinguish downward moves. For a simple rule, you might observe fewer correct predictions but larger average gains in the sample. For the model, you might find a reduction in errors that barely affects trades because it occurs near a threshold the trading policy never crosses.

The useful question is where the improvement appears. Examine decisions that change between competitors and calculate their consequences. An aggregate number alone makes it hard to distinguish better selection from an accidental change in position size. It also makes it easier to celebrate a prediction metric that has no material influence on the action.

7. A probability still needs a decision rule

A model may return a probability rather than an order. That allows uncertainty to be expressed, but it does not remove the need to decide what to do. The boundary between buying and abstaining depends on the outcome distribution, costs and objective. It need not automatically sit at fifty percent.

Imagine a fictional trade with only two gross outcomes: a gain of eight pips or a loss of five. Its complete cost is one pip, and its probability of winning is p. The simplified expected result is eight times p, minus five times one minus p, minus one: thirteen times p minus six. Break-even occurs at six divided by thirteen, approximately forty-six point fifteen percent.

If p were fifty-five percent, the calculation would give an expected gain of one point fifteen pips. But that conclusion depends on strong assumptions: only two outcomes, fixed outcome sizes, a known cost and a probability appropriate to this context. An estimated probability does not become true because it is displayed with two decimal places.

The Brier score loss compares predicted probabilities with observed outcomes using squared differences. It can help evaluate probabilistic forecasts against a constant frequency. It remains a predictive measure; improving it does not guarantee an improvement in the trading policy.

Keep calibration and discrimination conceptually separate. A model may rank higher-probability situations reasonably well while assigning probabilities that are too extreme. Alternatively, it may issue a sensible constant frequency without distinguishing any opportunities. Those behaviours matter differently around a decision threshold, and examining them requires enough observations to avoid overinterpreting small groups.

Do not adjust the threshold until the curve looks attractive and then attribute the entire improvement to the model. The threshold is part of the developed system. You can investigate it, but keep the variants and apply the same discipline to the references. A sophisticated output needs a translation into actions that is just as explicit as a one-line rule.

8. Filtering trades means examining the ones that disappear

Suppose a rule generates two hundred non-overlapping opportunities. In this exercise, all would become trades of the same size. Their combined gross result is one hundred and eighty pips, and each completed trade costs one pip. Taking them all therefore produces a net loss of twenty. This is the economic reference against which we want to investigate a filter.

The ML filter accepts eighty opportunities. They produce one hundred and twenty gross pips and incur eighty pips of costs, leaving forty net. The one hundred and twenty rejected opportunities produce sixty gross pips but would incur one hundred and twenty in costs, giving a contribution of minus sixty. The two subsets exactly reconstruct the reference’s loss of twenty.

A simple filter, written without ML before evaluation, accepts eighty different opportunities. In our invented example, these produce one hundred and thirty-two gross pips and fifty-two net. This does not establish universal superiority, but it does mean that the learned filter does not lead this comparison. Comparing it only with taking every opportunity would hide that information.

Two hundred hypothetical opportunities divide into eighty accepted trades earning forty net pips and one hundred and twenty rejected trades that would lose sixty; the original total is minus twenty.
Accepted and rejected opportunities should reconstruct the reference result.
Fictional procedure Trades Gross Costs Net
Rule without a filter 200 180 200 −20
Subset accepted by ML 80 120 80 40
Subset rejected by ML 120 60 120 −60
Rule with a simple filter 80 132 80 52

You can also calculate coverage: both filters accept forty percent of the opportunities. Matching the count makes one part of the comparison easier, but it does not ensure equal time exposure or equal risk. Eighty entries concentrated in a few trading days can behave differently from eighty spread across several months.

The rejection ledger helps expose conceptual errors. An opportunity rejected because data are missing should not be described as an intelligent choice by the model. If exits depend on earlier trades, dividing the ledger into subsets may no longer reconstruct the original strategy. Our example avoids that problem by using non-overlapping opportunities with outcomes independent of previous state.

For a system with shared state, simulate each complete policy. A filter may release capital, prevent a later position or change the quantity available for another entry. Its contribution is then more than the sum of removed rows. The baseline remains useful, but it requires coherent comparisons of complete account paths.

9. The calendar and the path are part of the opponent

Two procedures can finish with the same profit while creating very different experiences along the way. Consider these fictional cumulative paths in pips: zero, thirty, sixty, twenty-five, ten and fifty-five; versus zero, ten, twenty, thirty, forty and fifty-five. Both finish at the same value. The first falls fifty pips from its intermediate peak, while the second never falls between the displayed observations.

This is a deliberately artificial accounting illustration, not a market simulation. It also says nothing about movement between the observations. Its purpose is to show that a final result does not describe the path of losses. A real evaluation should state how frequently open positions are valued and what losses may be hidden by recording only trade closures.

When comparing a model and a reference, use the same opportunity calendar and document periods in which either could not make a decision. Do not allow a long indicator to begin several months later and silently compare its curve with the opponent’s full history. You can define a common eligible interval while retaining information about excluded observations separately.

TimeSeriesSplit provides chronological training and test partitions, with an optional gap measured in samples. Its documentation ties comparable test durations to equally spaced observations. It does not automatically turn an irregular Forex table into equivalent periods or know the information intervals associated with your labels.

Feature preparation also belongs to the version under comparison. Pipeline can chain transformations and an estimator. It helps organise the steps, while the permitted indices and fitting times remain choices in the experimental design. Putting a calculation inside a pipeline does not establish that its inputs were historically available.

We do not need to repeat the entire procedure for chronological evaluation here. The consequence for the baseline is specific: the information-access rules must be consistent. If the model updates at a specified frequency, record when the constant class frequency is recalculated too. If one competitor uses labels not yet known at decision time, the comparison no longer answers the original question.

10. Complexity must explain a concrete improvement

Adding machine learning introduces work: constructing features, training, saving artefacts, tracking versions, handling missing inputs and deciding when to update. Some tasks will be cheap; others will demand attention. You do not need to invent a monetary value for them to recognise that they belong in the decision about continuing the investigation.

Keep a small operational record: preparation time, training duration, failure frequency, artefact sizes and the effort needed to reconstruct a prediction. These observations do not replace the economic result. They describe the additional work the candidate would require if it eventually passed the other checks.

A conceptual matrix relates observed economic improvement to added complexity to guide further investigation without authorising deployment.
An observed improvement guides further investigation; it does not authorise trading.

A more complex model can be worthwhile when it solves a problem the reference does not solve. Make that problem identifiable: does it avoid costly entries, distinguish situations previously treated alike or improve an estimate used by another decision? Saying that it uses a modern architecture describes a tool, not its contribution.

Arnott, Harvey and Markowitz’s paper on backtesting protocols examines machine learning within disciplined financial research. We cite it for that methodological setting, not as evidence that an architecture or rule presented here will work in Forex. A published discussion of research practice cannot validate an unrelated candidate.

To investigate the contribution, remove components in a controlled way. Compare the full model with the same policy using fewer features or a constant output. If removing an information source barely changes the result, that source may not explain the apparent improvement. Record these tests too: they are additional development comparisons.

The paper on the probability of backtest overfitting by Bailey and coauthors examines selecting strategies among historical alternatives. The relevant lesson here is to preserve the researched set: an isolated winner does not describe the search that produced it. This article does not calculate that probability or propose a threshold for accepting a strategy.

A disappointing reference can still produce useful knowledge. The project may need better data or a different decision rather than more parameters. If every candidate depends on the same cost approximation and stops looking favourable after a small change to it, that limitation deserves attention before another training run.

11. A working notebook you can review with your AI

Start with the decision contract and a small set of fictional cases. Separate the opportunity file from the trade ledger. The first preserves what each system could have decided; the second records what it would have executed under the simulation. Keeping both prevents prediction coverage from being confused with the number of trades.

If you use a demonstration CSV, treat its contents as material for learning the workflow. A demo CSV does not establish sufficient coverage, permission for every use or strategy validity. This article does not promise additional market-history downloads. Identify available columns and missing information before asking an AI assistant to complete the analysis.

An opportunity row might contain a stable identifier, decision time, data status and each opponent’s action. A trade row should link to that opportunity and record quantity, entry, exit, gross result, cost components and net result. Timestamps need an explicit timezone, and units should be understandable without guessing from the filename.

Ask for clarification of the contract before requesting optimisation. For example: “Describe the decisions still missing for a comparison between abstention, a constant predictor and this four-bar rule. Do not select parameters by looking at outcomes. List ambiguities and give one example of the consequence of each.” That assignment can reveal gaps before code is generated.

Next, request bounded checks: “Create synthetic cases for a purchase, a sale, equal prices and incomplete data. State the expected action and reconcile one trade in the specified units.” Synthetic cases check behaviour. They should never later appear in a report as market performance or evidence of predictive ability.

The implementation request should preserve the references: “Implement a shared decision interface and common accounting. Export every opportunity, including abstentions and rejections. Do not add filters, position-size changes or parameter searches.” Review the resulting code and records. A well-written instruction does not guarantee that the implementation follows it.

Once there are numbers, change the assistant’s job from generating to reconciling: “Rebuild totals from the rows. Explain differences between opportunities, predictions and trades. Separate improvements in prediction, activity and economics. Mark missing information as unresolved.” This produces auditable questions and discourages plausible explanations that have not been checked.

Four parts of a review package: decision contract, opportunities, trades and comparison, each preserving a verifiable function.
The package reconstructs decisions, activity and accounting without relying on a model-generated summary.

Preserve versions of the contract, code and data alongside the simulation assumptions. A label such as “final model” does not identify the calculation that produced it. Another reviewer should be able to find a disputed row and trace it through its inputs, decision and accounting entry.

12. The conclusion you can write when the comparison ends

Your first conclusion should not be “AI works” or “AI is useless.” State the reference, what changed and the conditions of the comparison. For example: “In this exercise, the learned filter improves on taking every opportunity but falls behind the simple filter in net result; both accept the same proportion.” That sentence preserves the comparison without inventing generality.

If the model improves a prediction measure but not an economic measure, retain both. You can investigate whether the policy uses the information poorly, costs absorb the difference or the improvement occurs in observations irrelevant to entries. Those are explanations to test, not conclusions to select intuitively in order to protect the project.

A model that makes money in the sample but fails to outperform a simple reference need not be discarded automatically. It might have another function, but that function needs to be defined and measured. Avoid adding it afterwards as a vague justification. A negative answer to the original question deserves preservation even when it creates a new research question.

Beating a baseline is a reason to investigate more carefully, not a certificate of future profitability. Uncertainty, stability, execution and suitability for the intended use remain to be examined. The reference has helped locate a possible contribution. It has not removed those tasks or converted a teaching example into evidence.

For a final exercise, choose one trading decision you want to study and write down its simplest opponent. Add an alternative that stays flat and another that ignores your proposed features. Describe one observation that would make you abandon the candidate and one discrepancy that would make you revisit the accounting. If you can do this without naming an architecture, the problem is sufficiently defined to begin implementing.

The first useful deliverable is a comparison that can be reconstructed: what was known, what was decided, how much trading occurred and what remained after costs. That is the foundation for deciding whether training a model adds a worthwhile question to the investigation.

Three references to build before a model: staying flat, making a constant prediction and following a simple rule.
Each reference asks a different question about the value of adding a model.
Back to the Blog