ValidationIntermediate25 min read

Define the market regime before comparing the results

Build causal market-state labels, freeze their estimation rules and compare strategy outcomes without choosing regimes after seeing the winners.

A winding road crossing clear light, low fog and rain across a varied landscape
Conceptual image: a useful map of conditions is drawn before judging the journey through them.

The strategy became excellent after the researcher renamed the bad months

A researcher reviews a disappointing backtest and begins dividing the chart into market regimes. The profitable stretches become clean trends, the losing stretches become disorderly transitions and a few inconvenient days become exceptional events. The resulting presentation says that the strategy works well in its intended environment. But the environment was defined after the researcher had already seen where the strategy worked.

This fictional example does not mean that regime analysis is useless. It means that the rule used to label conditions belongs to the research design. A retrospective description can generate a valuable hypothesis, but it does not provide the same evidence as a comparison whose states and analysis were specified before the outcomes were inspected. The distinction is about information and selection, not about whether the labels sound economically plausible.

This article develops a practical way to define market states for evaluation. We will use hypothetical volatility labels, examine how their timing can leak future information and work through a simple change in the mixture of states. All thresholds and outcomes are invented for teaching. They do not describe the performance or private development process of TradeAndRoll systems.

The goal is to make the comparison reproducible. Another researcher should be able to assign the same label using the same information at the same moment, then calculate the declared outcome without moving the boundaries to favor a conclusion. A useful regime definition helps explain where evidence applies. It should not become a convenient vocabulary for excusing every result that conflicts with the original expectation.

Start with the decision the label is supposed to support

A regime label can serve several purposes. It may describe the historical environment, stratify an evaluation, enter a predictive model or control whether a strategy acts. These uses require different information boundaries. A label created with complete hindsight can be acceptable for a clearly retrospective description while being unavailable to a policy that must decide at the beginning of the period.

Write the intended use before choosing a classifier. If the question is whether a fixed strategy behaves differently across observable volatility states, the labels should be measurable at the stated evaluation time. If the question concerns what happened during a historical crisis episode, the event definition may be retrospective, but the result must be presented as an event study rather than evidence of a deployable regime detector.

Describing an episode and recognizing it in time are different capabilities. A beautiful chart that colors the final peak and trough precisely may describe the past well while offering no method to identify those turning points before later prices arrive. The report should not move between these interpretations without explaining the change.

Also identify the outcome being compared. Net daily result, exposure-normalized result, execution discrepancy and trade frequency are different targets. A regime may affect the number of opportunities as well as their average outcome. If the report uses only completed trades, it may overlook periods when the strategy was inactive or unable to act. The label definition and the outcome population need to fit the same research question.

Specify what the regime label is for before deciding how to construct it. This keeps the analysis from becoming a search for the most flattering partition. It also makes complexity easier to justify: a simple observable state may answer the intended question without requiring a sophisticated latent model whose labels are harder to interpret and preserve.

Make the information clock explicit

Suppose the intended decision occurs at the start of day t. A hypothetical volatility feature is calculated from the previous 20 completed daily log returns, ending at day t minus one. The label for day t can then be assigned using information available before that day’s outcome. If the feature instead includes the completed return of day t, it is not the same pre-day label.

The distinction can be small in code and large in meaning. A rolling calculation that includes the current row may be appropriate for a decision made after that row closes, but not for a decision made before it begins. The dataset needs to identify observation time, availability time and decision time where they differ. Matching on a date alone does not establish that the information was available.

For the first 20 observations, the specified history may be unavailable. Define what happens: no label, an explicitly separate warm-up category or another predeclared treatment. Do not silently fill the missing history with later observations. An unavailable state is not automatically an ordinary state. Treating it as ordinary can alter both the population and the apparent performance of that group.

External features introduce similar questions. An economic release has a publication time and may later be revised. A label based on the revised value is not necessarily the label available when the strategy acted. A session definition may depend on timezone and daylight-saving rules. A data-source change may alter the feature without any underlying market regime change.

The companion article on market drift and data-feed failures examines that last distinction. Here the practical requirement is a feature record that explains exactly what information each label used. Without that record, a regime table can be numerically reproducible from the final archive while still being unavailable in the chronological experiment it claims to represent.

A hypothetical day t label uses the previous 20 completed daily returns through t minus one, before observing day t's result
Hypothetical causal timing. Including the completed outcome of day t would answer a different information question.

Freeze how thresholds are learned, not just their final number

A threshold can be fixed directly or estimated from development data. In either case, the rule for choosing it matters. Suppose a hypothetical development sample produces a 70th-percentile volatility threshold of 0.8%. The evaluation labels day t as high volatility when the trailing feature exceeds 0.8%, and ordinary otherwise. Equality belongs to ordinary under this declared convention.

The threshold’s percentile origin does not imply that 30% of future days will be high volatility. That fraction described the development distribution under its quantile convention. A later period may contain more or fewer high-state observations. Forcing the evaluation sample to have the same proportion by recomputing the threshold on the full evaluation period uses information from that period and changes the definition.

The scikit-learn documentation identifies data leakage as using information unavailable at prediction time and emphasizes learning preprocessing from training data rather than the test set. Scikit-learn: common pitfalls and data leakage. A regime threshold, scaler or clustering transformation can create the same kind of information problem even when it does not directly use strategy profits.

Unsupervised does not mean free of information leakage. Estimating a transformation from future feature distributions can influence earlier labels. The issue is not only whether the outcome variable entered the calculation. It is whether the information set matches the intended chronological use. Preserve the development interval, estimation rule and resulting parameters alongside the labels.

A predeclared adaptive threshold is another legitimate design. For example, a rule may update from a specified past-only window. That is different from a permanently fixed 0.8% threshold and from a full-sample retrospective percentile. The label now means relative conditions under a changing reference distribution. Record that interpretation so the same category name is not mistaken for a constant absolute volatility level.

Turn a vague category into a reproducible state contract

A complete state definition needs more than a name. Specify the feature, units, lookback, availability rule, threshold, treatment of equality, missingness and update schedule. Also state whether labels are mutually exclusive and whether every eligible observation receives one. These choices make the category reproducible and prevent ambiguous rows from being handled differently after their outcomes are known.

Using the hypothetical 0.8% threshold, a trailing value of 0.7% is ordinary, 0.9% is high, a missing value is unknown and exactly 0.8% is ordinary. Those four rows form a small implementation fixture with known answers. They do not validate the threshold economically, but they test whether the written definition and the code agree at common edge cases.

Some classifications use persistence or hysteresis to avoid frequent switching. A hypothetical rule might enter a high state above 0.9% and leave it below 0.7%, preserving the prior state in between. This is a different stateful definition from the simple 0.8% threshold. It needs an initial-state rule and a record of prior labels. A stateful regime cannot be reconstructed from the current feature alone.

Do not introduce hysteresis only after noticing that one historical switching pattern hurts the strategy. It can be a sensible design choice, but it belongs to development and should be evaluated as part of the complete procedure. The same applies to minimum duration, smoothing and special event overrides. Each additional rule creates another way to select the population being compared.

A regime name should point to a specification, not to an impression. “Turbulent” may be a useful public label, but the research record needs the exact rule behind it. Clear definitions make disagreements productive: researchers can compare alternative specifications rather than arguing about whether a particular chart simply looks like a trend or a crisis.

A hypothetical threshold rule assigns 0.7 percent ordinary, 0.9 percent high, missing unknown and exactly 0.8 percent ordinary
Original edge-case fixture for a strict greater-than threshold. It checks implementation consistency, not predictive usefulness.

A changed mixture can alter the total without changing either state

Consider two hypothetical periods, each with 100 eligible days. In both periods, the strategy’s mean net daily result is positive USD 3 in the ordinary state and negative USD 2 in the high state. In the first period, there are 60 ordinary days and 40 high days. Total result is 60 times 3 plus 40 times negative 2, or USD 100, equivalent to USD 1 per eligible day.

In the second period, there are 30 ordinary days and 70 high days. Total result becomes 30 times 3 plus 70 times negative 2, or negative USD 50, equivalent to negative USD 0.50 per day. The state-specific means are unchanged in this invented construction. The aggregate deterioration comes entirely from the change in the mixture of states.

A worse aggregate result does not by itself identify what changed. It may reflect a changed state mix, changed outcomes within states, changed exposure or several mechanisms together. A regime table can help separate these possibilities if labels and accounting are comparable. If the state definition itself changed between periods, the comparison needs another layer of explanation.

The example is an arithmetic decomposition, not evidence that a real strategy has stable conditional means. In practice, each mean is estimated with uncertainty and the state mix may be dependent over time. Do not treat the displayed group averages as known constants simply because a weighted sum reconciles. The accounting identity can be exact while the inference about future behavior remains uncertain.

This decomposition also clarifies what a state filter would do. Removing high-state activity changes the policy and its exposure population; it does not merely reveal a hidden universally positive strategy. The revised system needs its own evaluation, including what happens around transitions and whether the label was available when the decision to act or abstain was made.

Two hypothetical 100-day periods keep state means at plus 3 and minus 2 dollars but change counts from 60 and 40 to 30 and 70, moving total from plus 100 to minus 50 dollars
Same conditional means, different state mix. The example is an original arithmetic construction, not a measured strategy result.

Decide how a position spanning several states is attributed

A trade can begin in one state, remain open through another and close in a third. Assigning its entire profit to the entry state answers a different question from allocating marked-to-market outcomes to the state observed each day. Neither convention is automatically wrong, but they describe different relationships and should not be mixed in one comparison.

Consider a hypothetical position opened during an ordinary state. It gains USD 50 on the first marked interval, then loses USD 80 during a high-state interval before closing. Its total is negative USD 30. An entry-state trade analysis assigns negative USD 30 to ordinary entries. A time-attributed account analysis assigns positive USD 50 to ordinary conditions and negative USD 80 to high conditions. These are two decompositions of the same path, not conflicting arithmetic.

Choose attribution to match the question. If the research concerns which entry conditions identify better completed trades, an entry-state analysis may be relevant. If it concerns how account exposure behaves while market conditions change, interval-level attribution may be more informative. The report should state how costs and overnight positions are assigned under the selected convention.

The distinction becomes especially important when the regime label itself changes while a position is open. A rule that stops new entries in the high state may still carry positions opened earlier. Reporting only the number of high-state entries can therefore hide substantial high-state exposure. Preserve the position ledger as well as the signal ledger so that abstention from new activity is not mistaken for absence of risk.

Do not choose the attribution after inspecting which version makes the preferred state look better. Declare a primary view and use other views as labelled diagnostics. If their conclusions differ, explain the economic question each answers. That difference can reveal an important mechanism, such as a strategy entering in quiet conditions but earning or losing most of its money during later transitions.

Count episodes as well as rows

Market states often persist. Fifty consecutive high-volatility days may belong to one extended episode rather than fifty independent environmental replications. A table with many rows can therefore contain limited diversity of experience. Report the duration and number of distinct episodes under a declared rule, alongside the number of days and trades.

The episode definition needs the same care as the state definition. Does a one-day interruption split an episode? Is a minimum duration required? Are gaps in data treated as unknown or as state changes? These choices can materially alter counts. If they are adjusted after looking at performance, the episode analysis acquires another layer of selection that should be documented.

The scikit-learn cross-validation guidance distinguishes independent data from time-dependent and grouped observations. Scikit-learn: cross-validation and dependent observations. The relevant point here is limited: evaluation should respect the dependence structure. Randomly scattering neighboring regime observations across folds can make the separation look stronger than the underlying information separation really is.

A populated cell is not necessarily a well-replicated condition. Show whether its outcomes come from many different episodes, instruments or sessions, and whether those sources are actually comparable. A cell dominated by one event can still be useful descriptively, but it should not be presented as precise evidence of a stable regime-specific advantage.

Keep missing and unknown labels visible in the coverage report. Excluding them may be necessary for a particular comparison, but their frequency and circumstances matter. If unknown labels occur mostly during feed problems or unusual conditions, the retained sample may systematically omit difficult environments. A clean-looking regime table should not conceal that its most important uncertainty lives in the rows it removed.

The calendar denominator deserves an explicit reconciliation. Suppose an archive covers 120 days, but only 100 satisfy the declared feature requirements. The state proportions describe those 100 eligible days, not the entire archive. List the remaining 20 with their exclusion reasons before interpreting the shares. If a separate performance summary covers all 120 days, the two tables will not necessarily reconcile until the excluded outcomes are accounted for. This is an accounting and coverage issue before it is a statistical one. Preserving that bridge prevents a difference in sample membership from being mistaken for evidence that the market changed its behavior.

Learned labels need stable meaning, not just stable names

A clustering or latent-state model can create categories without manually selecting a volatility threshold. That can be useful, but the labels still depend on features, estimation data, model settings and the assignment procedure. Calling a category state one does not give it a fixed economic meaning across model refits or datasets.

After a refit, category numbers can change while the underlying patterns remain similar, or the same number can describe a different region of feature space. A comparison that treats numerical label identity as semantic identity can therefore become misleading. Preserve interpretable summaries of each state and document how, if at all, states are matched across versions.

The assignment procedure must respect the intended information time. A method that revises earlier labels after observing later data can be useful for retrospective reconstruction, but those revised labels are not necessarily the labels available at the original decision. Keep the label issued at the time separate from the label reconstructed later. A final colorful chart should not overwrite the chronological record used to evaluate a policy.

Some methods provide uncertain state membership rather than a single certain label. Turning that output into hard categories introduces a threshold or decision rule of its own. Preserve the uncertainty where it matters, and explain how ambiguous observations enter the evaluation. A confident category name should not conceal that the model assigned nearly equal support to several states.

Complexity is justified when it answers a question that a simpler definition cannot answer well enough. It is not justified merely because the resulting chart looks more sophisticated. Compare the learned-state procedure with a transparent baseline, preserve its full estimation history and avoid describing discovered clusters as objective natural laws of the market.

Validate the complete labelling procedure

The object being evaluated includes feature construction, preprocessing, threshold estimation or clustering, assignment timing and the outcome comparison. Freezing only the final trading strategy while repeatedly redesigning the state labels leaves substantial research flexibility. The evaluation plan should identify which parts are fixed and which, if any, adapt according to a predeclared rule.

In a chronological evaluation, learn each required transformation only from the information permitted by the design. Apply the resulting procedure to the later observations without using their eventual outcomes to redefine states. If the design permits periodic refitting, record when it occurs and which data enter each update. The complete procedure, rather than one final fitted object, is the subject of the claim.

Do not search state boundaries on the evaluation results and keep calling them predefined. An exploratory search can reveal an interesting candidate partition, but the evidential role changes. Preserve that discovery and ask a subsequent evaluation to test the resulting procedure. The article on in-sample and out-of-sample separation provides the broader framework for this information boundary.

Multiplicity also extends beyond thresholds. Trying many feature windows, state counts, outcome metrics and attribution conventions creates many opportunities to find an appealing comparison. Record the search scope and distinguish the primary question from secondary exploration. A small set of coherent, predeclared comparisons is easier to interpret than a large dashboard from which only the most favorable cells are discussed.

If the research question changes during the work, document the change rather than pretending the original plan anticipated it. Learning is allowed. The important distinction is whether the final evidence is being used to describe what was discovered or to claim an independent confirmation of it. A clear record lets both kinds of work remain useful without merging their meanings.

A conditional association is not a causal explanation

Suppose a fixed label identifies days on which the strategy’s net result is lower. That is a conditional descriptive relationship under the sample and measurement convention. It does not by itself establish that the labelled feature caused the lower result. Other conditions may change at the same time: costs, exposure, activity, liquidity or the instruments represented.

Inspect those accompanying variables before writing an economic story. If high-state days also contain larger positions, a difference in dollar profit may partly reflect scale. If they contain more trades, average cost and total cost can tell different stories. If one state is concentrated in one calendar period, a broader historical change may be entangled with the label.

A useful regime table opens a mechanism question; it does not close it automatically. The next experiment might hold quantities fixed, compare cost contributions or examine a separate period with similar observable conditions. Those diagnostics can improve the explanation, but each has its own assumptions. Avoid turning a plausible narrative into a proven causal claim simply because the category names sound meaningful.

The same caution applies to policy changes. A strategy that acts only in ordinary conditions is a new strategy, with different opportunity selection and transition behavior. Its result cannot be obtained reliably by deleting all losing high-state rows from a stateful account history. The revised policy may change later positions and resource availability. It should be replayed and evaluated under its own declared rules.

This distinction protects the commercial purpose of research content. Source code and transparent rules make it possible to investigate conditional behavior and test adaptations. They do not guarantee that a discovered label will create a profitable filter. A useful article helps the reader formulate a testable modification instead of presenting a retrospective partition as a ready-made improvement.

Examine boundary sensitivity without moving the goalposts

A hard threshold creates a discontinuity in the label even when the underlying feature changes smoothly. Under the hypothetical 0.8% rule, values of 0.79% and 0.81% fall into different states despite being close. That is a property of the classification, not proof that the market’s economic behavior changes abruptly at exactly 0.8%.

Inspect reasonable sensitivity to nearby definitions during development. A conclusion that appears only under one very narrow boundary may depend on classification noise or selection. The purpose is to understand that sensitivity, not to choose whichever boundary makes the final evaluation look best. Once a primary rule is fixed for evaluation, alternative results should be labelled according to their exploratory role.

Measurement uncertainty near a boundary can become label uncertainty. Rounding, source differences or missing observations can move a feature across the threshold. Preserve sufficient numerical precision for calculation and state the comparison rule. Rounding a displayed 0.796% to 0.80% should not silently change a label that was computed from the unrounded value.

Transitions also deserve attention. A state may persist, alternate frequently or become unknown when data are unavailable. A policy that responds to labels can behave differently under these patterns even if the total fraction of high-state days is the same. Report switching frequency and time spent in ambiguous states when they matter to the research question.

Sensitivity analysis should reveal dependence on a definition, not conceal the search for one. Keep the tested alternatives and their rationale in the research record. If the analysis motivates a revised definition, treat it as a new version and evaluate it accordingly. This preserves the value of what was learned without allowing the evaluation boundary to drift unnoticed.

Write the report so the labels can be regenerated

The report should identify the state specification, feature and data versions, estimation interval, update rule and assignment time. It should state the outcome and attribution convention, coverage by state and treatment of unknown observations. These details let another researcher regenerate the labels before looking at the performance table, which is a useful check against retrospective interpretation.

Show state frequency separately from state-specific outcomes. Include counts of days, episodes, trades and exposure where relevant, while keeping their denominators clear. The reader should be able to distinguish a changed mixture from changed conditional behavior. If a state is poorly represented, say so directly rather than giving its mean the same apparent authority as a well-covered state.

Preserve the labels that existed when the evaluation was performed. Later data repairs or model refits may produce a revised label archive, but the revision needs its own version and explanation. Keep both when they serve different questions. Overwriting the original archive can erase the information history needed to interpret the earlier claim.

Separate the descriptive finding, its uncertainty and the proposed next action. For example, an observed difference can motivate more data collection or a candidate filter study without establishing a confirmed advantage. A specific, bounded conclusion is easier to use than a broad statement that the robot works in the right regime. The report should explain what right means and how that meaning was fixed.

A regime evaluation record preserves feature timing, threshold estimation, labels, outcome attribution and coverage before interpreting performance
Regenerate the labels independently of the outcome table. Their definition and chronology are part of the evidence.

Begin with a definition another person can apply

Choose one observable feature and write a short state contract before opening the strategy’s performance table. Include its timing, estimation data, thresholds and unknown category. Give another reader a few artificial rows and ask them to assign labels. If the answers differ, resolve the specification before interpreting differences in returns. This small exercise often reveals ambiguity that a polished chart would hide.

An AI assistant can help identify unavailable inputs, inspect boundary cases and compare the implemented labels with the written contract. Ask it to list every operation that learns from data and to identify which period supplies that information. Require it to preserve the distinction between an issued label and a later reconstruction. Do not ask it to invent regimes that explain away the losing parts of a known backtest.

The TradeAndRoll free demo contains ten Forex systems with rules, source code, market CSVs and research prompts. It offers concrete material for studying how a fixed system behaves across clearly defined conditions. Start with a narrow descriptive question, preserve the labels and treat any resulting strategy adaptation as a separate version that needs evaluation.

Define the weather before judging the journey. A market-state label becomes useful evidence when its information, meaning and timing can be reproduced without consulting the outcome it is supposed to explain. That discipline makes regime analysis a tool for learning where a conclusion applies, rather than a vocabulary for making every historical result sound inevitable.

Back to the Blog