RobustnessIntermediate23 min read

Your best parameter has neighbours: examining a trading robot’s robustness

Study parameter neighbourhoods, interactions, trades and costs without mistaking a stable region for a guarantee of future returns.

You change a window from twenty bars to twenty-one, and much of the result disappears. The code still runs, there is no error message, and the previous chart remains correct for its configuration. What has changed is the question: did the strategy depend on an identifiable mechanism, or on choosing precisely that window?

Before rejecting the robot, you need to inspect the trades. Perhaps a threshold excluded a single exceptional gain. Perhaps the window changed many entries. Or perhaps you compared different effective periods because each calculation required a different warm-up. A jump in the result is a clue to investigate, not a completed diagnosis.

In this article, you will learn to define what being close to a parameter means, compare entire regions and distinguish apparent stability from useful evidence. We will also examine how costs and the passage of time can change the interpretation of an attractive map.

Every robot, number, matrix and trade in this discussion is a hypothetical example constructed to explain the method. These are not results from Atlas or TradeAndRoll products. The context is a FOREX system without a specific instrument; nothing here prescribes a configuration for live trading. Robustness is described relative to particular changes. We will return to that distinction whenever it becomes tempting to call the entire robot robust.

1. The question a neighbourhood answers

A parameter is a choice that changes how a rule behaves: a window length, a threshold, a maximum holding period or an exit distance. A configuration brings those choices together. By varying some and holding others fixed, you observe how the system’s response changes under particular test conditions.

A neighbourhood is the set of configurations you decide to consider close to another. It might contain windows of eighteen, twenty and twenty-two bars, combined with three thresholds. Its usefulness depends on that proximity being meaningful for the rule. A cell’s position in a table does not, by itself, establish economic closeness.

The local question is specific: does acceptable behaviour persist under these perturbations? It does not establish whether the strategy can withstand every market, whether the code is free of errors or whether future profit will be positive. Local stability and the ability to generalise are different properties. A rule that never opens a position can produce a perfectly flat surface while being useless for the objective under investigation.

Nor is there a universal equivalence between flatness and good prediction. For certain deep networks, Dinh and his coauthors show that parameterisation can change the geometry without changing the represented function. Their finding is not a theorem about trading robots; it reminds us to justify what our definition of proximity measures. Dinh et al., Sharp Minima Can Generalize For Deep Nets.

Imagine two systems with the same net profit. One uses a precise threshold that selects a clearly defined event. The other changes smoothly because almost all its variants share the same trades. The second system’s smoothness deserves attention, but it does not demonstrate an economic advantage. The first system’s discontinuity needs explaining, but does not establish an error on its own either.

It therefore helps to finish the first review with a bounded description: stable under small window changes, sensitive to trading hours, or dependent on exit costs. These statements make it possible to decide what to investigate next. Calling something globally robust, without specifying the changes considered, removes precisely the information we need.

2. What counts as a small parameter change

Moving a window from ten to twelve bars increases its length by twenty per cent. Moving it from one hundred to one hundred and two increases it by two per cent. Both changes are two units, but they are not the same relative perturbation. Before drawing the map, decide whether you need an absolute distance, a proportional distance or one tied to an operational decision.

For a positive parameter spanning very different scales, exploring multiplicative relationships may be useful. For a trading time, however, five minutes may matter because it crosses an opening, a scheduled announcement or a session boundary. Proximity depends on the mechanism. No mathematical transformation automatically resolves that interpretation for you.

You must also distinguish numerical variables from categorical choices. Replacing a limit exit with a market order is not a small step along the same scale. It is a different execution instruction. You can compare them, but describe that comparison as a design variant instead of hiding it among the decimals of a continuous parameter.

Boundaries matter too. A window cannot have a negative length, and a maximum holding period may only accept integers. Near a boundary, the neighbourhood will be asymmetric. If one configuration has four valid neighbours and another has eight, reporting only the favourable percentage can hide the fact that you examined different regions.

The unit of change is part of the test. Record the actual values, their units, any rounding and the combinations excluded. If a threshold of 1.01 rounds to the same level as 1.02, those cells may represent exactly the same decision. A map full of identical colours might be showing discretisation rather than economic tolerance.

Consider the neighbourhood’s size as well. A tiny radius may leave every trade unchanged. An enormous one may combine strategies of a different nature. One useful practice is to declare a local neighbourhood and a wider one, each addressing its own question. Do not subsequently expand or shrink their boundaries merely to make the selected region look stable.

Your perturbation record should allow someone else to reconstruct the map without guessing what you considered close. Once that definition is clear, disagreements stop being arguments about a picture. They become reviewable decisions about how the strategy should be examined.

3. Freeze the experiment before colouring it

Suppose an educational rule uses an observation window and a threshold to decide when to participate. Before comparing parameters, we fix the historical data, effective calendar, position rules, size and cost treatment. We record which result we intend to measure and which constraints every run must satisfy.

Keeping the effective calendar consistent avoids a misleading comparison. A longer window needs more initial observations. If each variant begins trading when its own warm-up finishes, part of the difference may come from different dates. You can use a common starting point after the warm-up needed by all variants, documenting how much history remains available.

The primary metric is not enough either. Suppose you choose net profit as the map’s response. Retain trade count, exposure, losses and duration alongside it. One cell may improve because it assumes more risk or concentrates activity. The colour should represent what the legend says, without turning that single value into a complete assessment.

Selecting for stability is still selection. If you compare many radii, metrics and tie-breaking rules until you find a convincing surface, you are adjusting the selection procedure. Cawley and Talbot analyse how optimising a selection criterion on a finite sample can itself overfit. Choosing a region instead of a maximum does not eliminate that possibility. Cawley and Talbot, 2010.

Separate the material used to develop the diagnosis from what you will later use to evaluate an already fixed decision. We do not need to repeat an entire IS/OOS design here: simply acknowledge when an observed surface influenced your choice. If you change the rule after looking at it, record a new version and retain the previous one.

Specify how failures will be treated too. A run with insufficient data, an undefined calculation or an incomplete simulation must not silently become zero. Zero is a possible result; an invalid calculation is something else. Displaying them in the same colour can manufacture a boundary or plateau that does not exist.

By the end of this preparation, you will have a short contract: what varies, what remains fixed, what gets measured and what invalidates the comparison. That contract will be more useful than adding another colour layer to a map whose construction you cannot explain.

4. A peak of eighteen versus a region from seven to nine

Consider two different local regions within a search. The following values are invented net profits expressed in constant monetary units. They are neither percentages nor risk-adjusted ratios. Each table contains a central configuration and eight neighbours; its rows and columns represent three local values of the two parameters.

Region A Low threshold Central threshold High threshold
Short window −2 1 0
Central window 2 18 1
Long window 0 −1 2
Region B Low threshold Central threshold High threshold
Short window 7 8 7
Central window 8 9 8
Long window 7 8 7

The centre of A beats the centre of B: eighteen versus nine. Now exclude the centre of each summary to examine its eight neighbours. In A, their sorted values are minus two, minus one, zero, zero, one, one, two and two. Their median is 0.5. B has four sevens and four eights, giving a median of 7.5.

We can also count strictly positive neighbours: four out of eight in A and eight out of eight in B. The worst neighbouring cell is minus two in A and seven in B. These summaries show that, within these neighbourhoods, A’s centre stands out much more strongly from nearby alternatives. They do not turn B into an approved strategy.

Two hypothetical matrices: A has centre 18 and neighbouring median 0.5; B has centre 9 and neighbouring median 7.5.
Every cell is an invented configuration. Summaries exclude the central cell and are not probability estimates.

We still need to know whether the maps contain comparable activity. Region B could involve more trades, greater exposure or a substantial loss not reflected in this summary. Positive net profit does not describe its distribution over time either. We would need to open the records before establishing an economic preference.

Avoid reading eight out of eight as a one-hundred-per-cent chance of success. These neighbours are not eight independent futures: they reuse the same historical observations and may share trades. Counting cells does not mean counting independent evidence. The proportion describes a table under particular conditions, not the probability of making money tomorrow.

The useful decision here concerns the investigation. A needs an explanation for its central jump; B needs scrutiny of whether its apparent breadth comes from inactivity, duplication or shared favourable assumptions. Both questions are more precise than automatically choosing the strongest colour or the largest patch.

5. Interactions that a single line cannot show

Varying one input while holding the others fixed is an understandable inspection. You can see what happens when you lengthen the window at the central threshold. However, the response to one parameter can depend on another parameter’s value. One horizontal line and one vertical line do not necessarily describe the rest of a surface.

The NIST handbook explains this limitation of changing one factor at a time when interactions exist. The idea we need is modest: the effect of changing an input may depend on another input. We are not importing an industrial experimental design as certification of a financial strategy. NIST, One variable at a time.

Let us construct a second, independent example. With a short window, moving from the low threshold to the high threshold changes the result from eight to twelve: an improvement of four units. With a long window, the same change takes the result from eleven to three: a decline of eight. The direction of the response reverses depending on the window.

Hypothetical interaction: raising the threshold improves the result by four units with a short window and worsens it by eight with a long window.
The difference between the two effects is twelve units. This is an arithmetic comparison within the example, not a significance test.

A recommendation about the threshold must specify the window. If you average the effects without displaying their conditions, you can lose precisely the combination that explains the behaviour. In a robot, an interaction may arise because the window changes the set of opportunities on which the threshold acts.

With more parameters, every two-dimensional map is a slice. A broad region may only remain broad while a third choice stays fixed. Rather than demanding pictures that are impossible to read, select slices justified by the logic of the rules and declare which coordinates remain constant. Investigate combinations that may share an operational function first.

You do not need to examine every imaginable interaction before learning anything. You need to avoid making a broader claim than your inspection supports. If you only varied the window and threshold, discuss sensitivity to those two choices. Keep questions about duration, timing and execution open until a specific comparison addresses them.

6. Open the result map and inspect its trades

Two nearby configurations may produce similar results for very different reasons. They might open the same positions at slightly different prices. They might select completely different trades whose totals happen to match. The first situation suggests continuity of decisions; the second requires a closer look at the kind of stability being measured.

Define in advance how you will recognise an equivalent trade. You might use the instrument, direction and signal time, with an explicitly stated timing tolerance. Comparing trade counts alone is insufficient. Two sets of one hundred trades may overlap almost completely or share none at all, and that distinction changes the map’s interpretation.

In another hypothetical example, one configuration produces one hundred trades and its neighbour produces one hundred and four. Ninety-six are shared under the chosen definition. Their union contains one hundred and eight: one hundred plus one hundred and four minus ninety-six. The intersection-to-union ratio is 96/108, approximately 88.9 per cent.

Hypothetical trade sets: 4 exclusive to A, 96 shared and 8 exclusive to B, with a union of 108.
Overlap is defined by signal identity. It does not imply identical prices, sizes or results.

That percentage is not a universal quality threshold. It directs the inspection. Start with the four trades exclusive to the first configuration and the eight exclusive to the second. Check whether they are small decisions spread across time or whether they account for almost the entire profit difference.

Then inspect the shared trades. They may retain their identity while their exits, size or duration change. A high overlap count can coexist with different exposures. Retain one comparison of decisions and another of consequences: entry, exit, size, cost and contribution to the result.

A plateau can conceal a shared concentration. If every variant retains the same exceptional trade, their profits will move together. Examining what happens without that episode is a concentration check, not permission to delete inconvenient losses. Declare the analysis and preserve the original result, showing how much of the argument depends on that event.

7. How much information supports each cell

A cell with six trades and one with six hundred do not have the same descriptive support. Six hundred consecutive trades do not necessarily provide six hundred independent observations either. They may cluster in one condition, overlap, or depend on the same market move. The map needs information about activity and distribution as well as results.

We will not prescribe a universal minimum trade count. The amount needed depends on the question, variability and dependence among outcomes. What we can do is avoid unexplained comparisons: report closed trades, positions remaining open at the end, time in the market and periods without activity.

An apparently stable region may include variants whose filter never activates. If all display zero, the surface will show little variation. That does not demonstrate signal robustness; it shows that, under these conditions, you observed very few decisions. Absence of activity needs its own label.

Another difficulty arises when the parameter changes trading frequency. A longer holding period may reduce the number of entries because the robot remains occupied. Comparing profit per trade without considering committed time would encourage an incomplete interpretation. Examine the total, distribution and exposure without subsequently searching for the most attractive denominator.

If you repeat the calculation across blocks, preserve their composition. A block with many opportunities does not provide the same observation as one with very few. Uneven information is not corrected by hiding every point behind an average. You can display results by block alongside activity and explain where the available observation is insufficient.

There is simulation uncertainty too. A rule depending on the order of prices within a bar may have ambiguous fills even when it accumulates many trades. Increasing the number of configurations does not automatically improve the underlying information. Before interpreting a rough surface, ask whether some roughness comes from simulator conventions.

A careful reading of the available support may leave you with an uncomfortable but useful finding: there is not yet enough information to compare these neighbours. That conclusion limits the study’s scope. It is preferable to turning cells with very little activity into strong arguments simply because their colours match.

8. Stability can disappear when friction enters the picture

Return to two invented configurations, independent of the earlier matrices. C generates a gross profit of one hundred and twenty units over one hundred completed trades. D generates one hundred gross units over fifty trades. To keep things simple, all trades use the same size, and each completed trade bears a constant total cost in the currency of the result.

At a cost of 0.5 units per trade, C pays fifty and retains seventy; D pays twenty-five and retains seventy-five. At a cost of one unit, C retains twenty and D retains fifty. We have not changed their rules, but the preference based on net profit no longer matches the gross ranking.

Hypothetical configuration Gross Trades Net at cost 0.5 Net at cost 1
C 120 100 70 20
D 100 50 75 50
Hypothetical net results: C falls from 70 to 20 and D from 75 to 50 when the cost per completed trade doubles.
Cost is the total per completed trade. It does not represent a pip, a real spread or an intermediary’s fee.

A neighbourhood shares assumptions too. If every result omits a material cost, a broad plateau can be broadly wrong. It therefore helps to cross configurations with friction scenarios while retaining a common basis. Do not subsequently choose a different cost to protect each candidate.

The constant-cost example only explains the arithmetic. In an actual investigation, spreads, commissions, financing and slippage can depend on the instrument, time and execution. The purpose of an adverse scenario is to examine sensitivity to a reasoned assumption, not to claim that the scenario covers every possible future situation.

Also check whether the parameter changes exposure to precisely those costs. One variant may move trades into less liquid hours or hold positions for longer. Applying the same average figure to every variant simplifies the exercise, but may hide the mechanism producing the difference.

The comparison should show which friction can change the decision. A statement such as “D retains more profit in these two cost scenarios” can be checked. “D is protected against costs” would be much stronger and is not supported by the exercise. Keep the first statement and use its limitations to design the next investigation.

9. A stable neighbourhood on the selection calendar

A surface is built from particular observations. Many parameters behaving similarly during those observations does not guarantee the same behaviour later. The next step is to examine an already defined selection rule as the calendar advances, without reinterpreting each period using knowledge of what subsequently happened.

You can divide observations into chronological blocks to compare stability. State whether you seek persistence of one configuration, continuity of a region or performance of a selection procedure. These are different objects. If you retrospectively choose the best point in each block, you are not showing the path of a robot that could have known those decisions in time.

The TimeSeriesSplit documentation describes temporally ordered divisions and a parameter separating training and test observations. It also notes sample-spacing requirements for comparing durations. That tool does not decide whether overlapping trades or information windows require additional exclusions in your case. Official TimeSeriesSplit documentation.

In our educational protocol, we would fix a configuration before opening a reserved block. Within that block, we would observe its behaviour, together with the previously declared local neighbourhood if that diagnosis had been planned. Inspecting neighbours to choose a different point retrospectively makes the block development material for that new choice.

The timeline must include the researcher’s decisions. Record when you changed the radius, discarded a metric or expanded the search universe. The price calendar alone does not reveal when you learned something that influenced the design.

If the stable region moves, do not automatically conclude that you only need to follow it. This might indicate changing economic dependence, a scale problem or sample variation. To investigate adaptation, you would need to define when recalibration happens, with what information and under which criterion. That whole procedure becomes the object of evaluation.

The region might also retain its shape while every value worsens. Relative stability across parameters would coexist with absolute deterioration. Your report therefore needs to display both the geometry and the level of results, retaining comparable scales between periods rather than letting each picture choose its own flattering range.

10. Searching more finely creates more choices too

A grid makes relationships easier to see, but its size grows quickly. Five values for each of two parameters produce twenty-five combinations. For six parameters, they produce fifteen thousand six hundred and twenty-five. Every additional dimension consumes resources and increases the opportunities to find something striking in the same history.

The SciPy documentation illustrates this exponential growth for exhaustive search. The computational fact does not determine your experimental design: it requires you to budget the search space and describe what was actually explored. SciPy, optimize.brute.

Bergstra and Bengio study random search as an alternative to grids in machine-learning hyperparameter optimisation. It is a reference on allocating a search budget, not evidence of trading-robot profitability or an automatic correction for overfitting. Bergstra and Bengio, 2012.

For our problem, distinguish discovering regions from describing a region. Broad sampling may inform the initial exploration. An explicit local grid can then help inspect particular neighbours. Both steps belong to the selection history; the second does not erase the decisions that led to the first.

Bailey and his coauthors present a framework specifically addressing backtest overfitting and selection among configurations. The relevant lesson here is to preserve the alternatives considered: a result selected from many trials has a different history from a proposal fixed before observing them. We are not calculating their probability of backtest overfitting from our small maps. Bailey et al., The Probability of Backtest Overfitting.

A more detailed map does not necessarily contain new evidence. It can be a new way of questioning the same observations. If you add points around a promising area, record that adaptive choice. Do not later present the region as if it had been your only original proposal.

Reserve resources for inspecting trades, data and scenarios as well as generating candidates. Sometimes investigating why twelve transactions change teaches more than running another ten thousand combinations. The budget should follow unresolved questions rather than the number of cells your computer is capable of colouring.

11. Choose a region without inventing another competition

After observing a plateau, it is tempting to create a score that rewards exactly its characteristics. You can combine profit, neighbouring median, worst case and region size until you obtain your preferred ranking. The procedure may look rigorous, but its weights will also be decisions made after looking at results.

A more transparent alternative is to declare necessary conditions first. For example, exclude invalid comparisons, require enough activity for the question and reject violations of exposure limits. You can then apply a descriptive stability criterion. Specific values need contextual justification; do not inherit them from this article as universal rules.

If several points meet the conditions, the tie-break deserves an explanation too. Selecting a simple configuration, one away from a problematic boundary or one representative of a region may be reasonable for a study. It does not mean that the geometric centre is always superior. Units and constraints on each coordinate change what being central means.

The selection rule must be fixed as well. Specify what happens with ties, invalid cells and the absence of candidates. Allowing the procedure to return “no configuration” avoids forcing a favourable decision when the observations do not support what you hoped to find.

Do not confuse choosing a representative with combining the entire region. Running many variants together creates a portfolio with its own sizes, overlaps and costs. Averaging historical profits does not automatically describe an implementation that can be traded. The combination would need additional rules and an assessment of the whole system.

Retain the candidates you did not choose and the reasons. This makes it possible to examine whether the decision followed a prior constraint or a later preference. It also stops memory from turning a practical compromise into a supposed demonstration of superiority.

The conclusion can remain provisional: we selected this version for subsequent evaluation because it meets stated conditions and its neighbourhood is interpretable. That is a defensible research decision. Claiming to have discovered the true parameter would require different and much stronger evidence than a historical surface provides.

12. A complete exercise before changing the configuration

Imagine receiving a table containing A’s centre of eighteen units alongside a heavily smoothed image. Your first task is to request the original cells. Then request their coordinates, effective calendar, costs, trades and treatment of invalid calculations. You do not yet need to propose a different parameter.

Using the values in section four, calculate the neighbouring median and the number of strictly positive results again. You will obtain 0.5 and four out of eight. Check that you excluded the centre. Including it would produce a median of one, which is a different description. Neither convention is intrinsically illegitimate; it must be defined and retained throughout the comparison.

Your second task is to locate the operational explanation for the jump. Write down three possibilities before opening the record: an exclusive gain, a broad change in decisions or a difference in the calendar. Seek evidence that distinguishes them. If you only try to confirm your favourite explanation, you waste information the example could provide.

The third task is to examine region B. Its neighbouring median of 7.5 looks better under this diagnosis. Ask whether the eight configurations share the same events and respect the same constraints. Almost complete overlap can explain smoothness without providing eight separate checks.

A four-part protocol: define perturbations, inspect decisions, fix selection and evaluate later.
Each block produces a different record. Subsequent evaluation retains its purpose only when it is not used to retouch the choice it is intended to examine.

Finally, write two conclusions. An admissible one would be: “Across the eight declared neighbours, B has a higher minimum net profit than A under these assumptions.” An inadmissible one would be: “B is certain to be profitable because everything around it is positive.” The difference concerns the scope of the conclusion, not the addition of a warning at the end.

If you use AI for assistance, ask it to check the arithmetic, list assumptions and identify missing information. Provide complete tables and require a distinction between supplied facts and hypotheses. Do not ask it to certify robustness from a screenshot. A convincing explanation must be checked against the trades and original files.

13. What to preserve for a reviewable diagnosis

The outcome of this work should be more than an image. Save the rule version, coordinates of every combination, historical data used and execution conventions. Add the displayed metric, auxiliary results, invalid cells and the criterion used to select a representative configuration.

Keep the intermediate steps too. If you first explored a wide range and then narrowed the study, record both. If a new question emerged while reviewing trades, identify it as a later observation. This shows which decisions came first and which arose from the analysis, without pretending that the research followed a straight line when it did not.

A short report can separate three columns: observation, interpretation and next check. “Four positive neighbours out of eight” belongs in the first. “Possible dependence on one trade” belongs in the second until the records have been inspected. “Compare contributions from exclusive trades” belongs in the third. Mixing those categories turns reasonable suspicions into premature conclusions.

The conclusion must name its limitations. You may have examined two parameters, one period and two cost scenarios. Other configurations, liquidity conditions, data errors and future changes remain outside that scope. You do not need to list infinite risks; you do need to state which specific questions remain unanswered and which could change the decision.

The connection with a delivered robot is practical: its rules and source code let you identify choices and inspect their implementation. This does not mean that every parameter should be adjusted or that a modification inherits the evaluation of the original version. TradeAndRoll’s initial scope is FOREX, and market-data CSV files are included exclusively with the demo; the examples in this article are independent of those materials.

When you return to the twenty-bar and twenty-one-bar windows, you will have a sequence for investigating the jump: verify comparability, inspect decisions, study neighbours and fix what to evaluate next. The best result will no longer dominate the entire conversation. Its surroundings, assumptions and underlying trades will also need to explain why they are there.

Before choosing a representative from the parameter region, check how the choice fits the separation between in-sample and out-of-sample data. Record every region inspected in the trading experiment journal, so the final report preserves the search that led to the selection.

Conceptual comparison of a narrow peak and a broad region with similar results.
The height of one result and the behaviour around it answer different questions. Educational schematic without market data.
Back to the Blog