Systems and executionIntermediate25 min read

One decimal changes the order: rounding without changing the rule

Distinguish price precision from valid ticks. Study directional rounding, decimal arithmetic and boundary checks without silently changing a robot's rules.

A precise brass caliper beside a blue ceramic tile on cream paper in soft natural light
Conceptual photograph: translating a continuous measurement into a permitted increment.

The formula has more decimals than the instrument allows

The research notebook produces a threshold of 1.100035. The platform displays five decimal places. Someone rounds the value to 1.10004, the request passes a numerical check, and the difference seems too small to discuss. Yet that choice may allow a hypothetical purchase above the intended maximum, move a trigger earlier or change whether a candle qualifies as an entry.

The problem is not that rounding is inherently inaccurate. A discrete price system requires a translation from a calculated level to an accepted level. The problem is allowing a general-purpose numerical default to choose the economic meaning of that translation. A method that is appropriate for a display label may be inappropriate for a maximum price constraint.

Rounding belongs to the rule specification when it can change a decision. It should be visible in the research record, tested at boundaries and applied consistently when comparing versions. Hiding it inside a helper function does not make the decision disappear; it only makes the resulting differences harder to explain.

The prices and instrument rules below are hypothetical teaching examples. They do not describe the current specifications of a particular Forex pair or provider. We will examine grids, inequalities and arithmetic representations as documentary research questions. There is no order-submission code, and numerical validity should never be confused with confirmation that an actual transaction can execute.

Decimal places and a price grid are different things

A value displayed with two decimal places can take any hundredth in that display system: 100.01, 100.02 and so on. An instrument with a hypothetical tick increment of 0.25 permits a smaller set, such as 100.00, 100.25, 100.50 and 100.75. Displaying 100.13 to two decimal places does not make it an admissible price on that grid.

For a grid anchored at zero with increment 0.25, a valid price is an integer multiple of 0.25. The price 100.25 corresponds to 401 increments. The price 100.13 corresponds to 400.52 increments and is not on the grid. The relevant operation is therefore quantization to permitted increments, not merely limiting the number of printed decimals.

The same distinction can appear at smaller scales. On a hypothetical grid of 0.00005, the levels 1.10000, 1.10005 and 1.10010 are valid. A calculated 1.10003 has five decimal places but is not valid on that grid. On a different hypothetical grid of 0.00001 it would be valid. Instrument metadata, not visual familiarity with Forex quotes, determines the applicable set.

Do not infer the increment from a screenshot. A display can add trailing zeros, suppress digits or show an indicative value that is not an allowed instruction price. Provider documentation may distinguish display precision, pip location and quantity precision as separate fields; OANDA’s instrument definitions provide a concrete example. Instrument metadata.

In a research record, identify the price increment, grid origin if relevant, permitted precision and any price-dependent bands. If the instrument uses different increments in different ranges, one global decimal count is especially inadequate. The examples here use a constant zero-anchored grid so that the mathematical decisions remain easy to inspect.

A hypothetical quarter-unit grid allows 100.00, 100.25, 100.50 and 100.75; 100.13 has two decimals but lies between valid levels
Visible decimal places do not define the permitted set. The hypothetical increment is one quarter, not one hundredth.

A grid also has an origin and sometimes a boundary

The constant grids above were anchored at zero. That assumption makes an integer multiple of the increment sufficient to identify a permitted value. In a more general mathematical specification, the allowed set can be an origin plus an integer number of increments. The origin belongs to the definition, even when it happens to be zero in the instrument being studied.

Consider a purely hypothetical grid with origin 0.02 and increment 0.05. Its permitted values include 100.02, 100.07, 100.12 and 100.17. A raw threshold of 100.13 lies between 100.12 and 100.17. A zero-anchored downward calculation would instead suggest 100.10, which is not on this invented grid. The correct mapping first considers distance from the origin, applies the integer policy and restores the origin.

This example is not a claim that a particular Forex provider uses that offset. It demonstrates why a reusable mathematical description should not silently assume more than the specification states. A researcher can explicitly record a zero origin when that is the declared model, keeping the simplification visible rather than embedding it as an unexplained universal rule.

Crossing a price band can require checking the candidate against its own band. Suppose another hypothetical instrument permits increments of 0.01 below 100 and increments of 0.05 at and above 100. A raw value close to 100 can map across the boundary. The final candidate needs to satisfy the increment and boundary convention applicable at that candidate, not merely the increment selected from the unrounded input.

For example, a hypothetical upward mapping from 99.999 can legitimately reach 100.00 under the stated bands. A candidate of 100.01 would not be permitted in the upper band, despite having two decimal places. The implementation must know whether the boundary belongs to the lower or upper interval; a vague phrase such as prices around one hundred is not enough to decide.

Validate the final candidate against the full permitted set. An intermediate rounding operation can be internally correct and still produce a value that violates another part of a piecewise specification. A documentary test should therefore include values on both sides of a band boundary and exactly at it, along with a clear statement of which convention owns equality.

These extra cases are unnecessary if the actual research environment has a simple constant zero-anchored grid. They become necessary when the specification is more complicated or when a numerical helper is reused across instruments. The purpose is to keep complexity proportional to the real contract while ensuring that a convenient assumption does not masquerade as an instrument fact.

Write the inequality before choosing the direction

Suppose a hypothetical research rule says a purchase must cost no more than 1.100035. With an increment of 0.00001, the neighboring valid levels are 1.10003 and 1.10004. Rounding to 1.10004 violates the stated maximum, while rounding to 1.10003 preserves it. This conclusion comes from the inequality, not from an intuition that rounding up or down is always safer.

Now suppose a hypothetical sale must receive at least 1.100035. The level 1.10003 falls below the stated minimum; 1.10004 preserves it. The same raw number therefore maps to different valid levels under different economic constraints. A single nearest-tick function cannot preserve both meanings automatically.

A maximum acceptable purchase price and a minimum acceptable sale price are different contracts. For the constant grid in this example, a downward mapping preserves the purchase ceiling and an upward mapping preserves the sale floor. That statement describes price bounds only. It does not guarantee completion, account suitability or the validity of any other order condition.

The distinction is useful when comparing a continuous mathematical rule with its discrete implementation. Store both the raw threshold and the chosen valid level. The difference is a quantization adjustment. It should not be mislabeled as execution slippage, because it occurs before any actual fill is observed.

Choose the direction from the condition you intend to preserve. If the original rule does not state whether its threshold is a ceiling, a floor or an approximate target, the ambiguity belongs in the specification. Guessing a direction and proceeding can produce a numerically tidy result whose economic meaning was never agreed.

Nearest rounding has its own purpose and its own tie rule

Nearest rounding minimizes the distance to the chosen grid under a specified distance measure, but it does not necessarily preserve a one-sided constraint. It may be suitable for an approximate reference level or a visual summary. It should not be substituted for a ceiling or floor policy simply because it is a library’s default.

On a hypothetical increment of 0.00001, the value 1.100035 lies exactly halfway between 1.10003 and 1.10004 in decimal arithmetic. A half-even policy chooses the candidate whose integer tick count is even, giving 1.10004. At the separate halfway value 1.100025, half-even gives 1.10002. Both follow the same rule, although one moves upward and the other downward.

Other tie policies choose differently. The Python decimal documentation explicitly distinguishes nearest variants and directional modes, including floor, ceiling and movement toward zero. Decimal rounding modes. The practical lesson is to name the policy rather than rely on an everyday phrase such as ordinary rounding.

A tie test needs an exact halfway input. If the raw number was first approximated in binary floating-point arithmetic, the stored value may lie slightly above or below the intended halfway point. A result that appears to violate the documented tie policy may actually reflect a different stored input. Inspect the representation before diagnosing the numerical library as inconsistent.

Include just-below, exact-halfway and just-above values in a documentary test table. The expected answer should be calculated independently from the stated grid and policy. A test that merely repeats the same library call used by the implementation cannot establish that the chosen policy matches the economic rule.

A trigger boundary is not the same as a price guarantee

Consider a hypothetical rule that becomes eligible only when a reference price reaches or exceeds 1.100045. On an increment of 0.00001, the first grid level satisfying that condition is 1.10005. Moving the threshold down to 1.10004 would allow eligibility before the original condition is met. If preserving no-earlier activation is the objective, the upward boundary is the appropriate mathematical translation in this simplified model.

For a condition that becomes eligible when the reference falls to or below 1.100045, the first valid level at or below the threshold is 1.10004. Moving it up to 1.10005 would allow an earlier downward crossing. These are trigger-condition examples, not claims about the eventual transaction price or every provider’s trigger convention.

Separate the activation boundary from the execution price. A stop-like trigger may initiate another process whose execution occurs at a different price under the applicable rules. Rounding the trigger to a valid tick does not turn it into a guaranteed loss cap. A research report should preserve the reference side, crossing condition and execution assumption as separate pieces.

The limit-order discussion explains why a price observation does not establish a fill. Here the same principle protects the meaning of a threshold: numerical eligibility is one condition in an event sequence. Even a perfectly rounded boundary can be evaluated against the wrong quote side or at the wrong time.

When a research specification uses phrases such as above, at least, below or at most, translate them into explicit strict or inclusive comparisons. Equality matters on a discrete grid. A strict condition above a level already on the grid can require the next tick, whereas an inclusive condition can accept the existing tick. That difference should be intentional and visible.

For raw value 1.100035 on a 0.00001 grid, preserving a purchase maximum chooses 1.10003 and preserving a sale minimum chooses 1.10004
The same calculated number has different valid translations when the intended inequalities differ.

A protective boundary exposes competing objectives

Suppose a hypothetical long-position study uses entry 1.10050 and a protective reference level of 1.099965. On a 0.00001 grid, the neighboring candidates are 1.09996 and 1.09997. The lower candidate is farther from the entry; the higher is nearer. A choice described simply as conservative is ambiguous because there are several possible objectives.

If the objective is not to increase the nominal entry-to-boundary distance, the higher candidate preserves that condition in this simplified example. If the objective is never to activate before the continuous model’s downward threshold, the lower candidate preserves that different condition. Both cannot be assumed equivalent just because the difference is one tick.

Document the tradeoff instead of hiding it in rounding. The relevant research decision may be to allow a stated approximation, reject an infeasible combination or revise the mathematical specification before further testing. A generic downward policy for every numeric field can increase one distance while preserving another unrelated inequality.

The nominal distances are 0.00054 for the lower level and 0.00053 for the higher. At a hypothetical quantity of one hundred thousand base units, their difference corresponds to one quote-currency unit under a simple linear price-difference calculation. This is a calculation of nominal distance, not a bound on actual loss in the presence of gaps, costs or a different execution price.

A one-unit difference may look small, but the boundary can also alter whether a simulated exit happens before a subsequent price movement. The result is not always a smooth one-unit adjustment to the same trade. When the rule changes an event’s classification, the entire subsequent path may differ. That is why the rounding convention belongs in the reproducible rule definition.

Binary representation can turn an exact boundary into a near miss

Many common decimal fractions do not have exact finite representations in binary floating-point arithmetic. A displayed number can therefore hide a tiny representation error. The decimal documentation illustrates the distinction between constructing decimal values from exact decimal text and converting an already approximated binary number. Decimal arithmetic.

In a hypothetical boundary test, a value intended to equal one hundred tick units might be stored as 99.99999999999999 tick units. Applying a strict floor would yield ninety-nine, one entire tick below the intended boundary. A tiny representation difference has been amplified into a discrete decision because the operation occurs at an integer boundary.

Distinguish representation error from an intentional tolerance. Adding a small arbitrary constant everywhere may fix that example while breaking another. The appropriate scale depends on the units and calculation path, and a blanket adjustment can change genuinely sub-boundary values into eligible ones. A tolerance is a policy that needs a reason and a test domain.

Decimal arithmetic or scaled integer tick representations can make some invariants easier to express, provided the conversion is itself correct. They do not eliminate every source of error. A calculated ratio may still require rounding, an input may already contain an approximation, and a finite-precision decimal context can round intermediate operations.

The research note should identify where external decimal text becomes a number, which operations may be inexact and where the final grid decision occurs. This is not a request for a particular programming language. It is a demand that the numerical representation preserve the rule’s stated boundaries rather than allowing invisible intermediate approximations to choose them.

Rounding twice can differ from rounding once

Imagine a hypothetical value of 1.23446 that is first rounded to four decimal places using nearest-half-up, producing 1.2345. If that intermediate value is then rounded to three decimal places using the same policy, it becomes 1.235. Directly rounding the original 1.23446 to three places gives 1.234 because the next digit is four. The extra intermediate step changes the final answer.

This example concerns decimal-place rounding, but it illustrates a general pipeline risk. A value may be shortened for a report, copied back into a calculation and then quantized to an instrument grid. A harmless display transformation has become an input transformation. The final output can differ even though every individual rounding operation follows its documented rule.

Preserve the research value until the specified quantization boundary. A display version and an economic calculation value should not be silently interchangeable. If an intermediate rounding step is part of the strategy definition, document it as such. Otherwise the implementation should not introduce it merely because a table looks cleaner with fewer digits.

The same issue appears when one component stores a price at one precision and another reads it with a different assumption. A faithful comparison needs the original value or a declared serialized representation that preserves the required information. A rounded screenshot cannot recover the digits that a later boundary test needs.

Repeated translation can change the rule even when each step looks reasonable. Trace the value from formula through storage, display, export and final grid mapping. This review often identifies differences between a research notebook and an adapted implementation that would otherwise be misdiagnosed as market randomness.

Price validity is only one part of instrument validity

A level can sit exactly on the grid and still violate another condition. A hypothetical provider might require a minimum distance from a reference quote, impose a permitted price range or apply different conditions to a particular order type. These constraints need their own documentation and should not be inferred from the tick increment.

Suppose a research rule permits a maximum distance of 140 ticks while the modeled environment requires a minimum distance of 150 ticks for the chosen instruction. No price can satisfy both conditions. Rounding a candidate farther away until it is accepted changes the research risk condition; rounding it nearer preserves the research condition but leaves the environmental constraint unsatisfied.

An empty feasible set should remain visible. The appropriate research outcome is a documented incompatibility, not an automatic alteration that makes a request appear successful. The rule, target environment or scope of the study needs reconsideration before the evidence can support that adaptation. Numerical acceptance alone is not the objective of a faithful translation.

Quantity has separate increments and minimums as well. A valid price does not make an invalid quantity acceptable. Conversely, reducing quantity to meet a capital constraint does not repair a price that lies off the permitted grid. Keep price quantization, quantity quantization and account-level constraints separate in the report, then examine their interaction explicitly.

The position-size sensitivity article provides context for those interactions. A change in one tick can alter nominal distance and therefore a size calculated from that distance. If the size then rounds to another quantity step, a small price adjustment can produce a larger discontinuous exposure change. The final experiment should preserve both stages rather than treating rounding as a purely cosmetic detail.

A hypothetical research maximum distance of 140 ticks and environment minimum distance of 150 ticks have no overlapping valid range
A valid grid cannot solve incompatible constraints. The empty intersection is a research finding that should not be hidden by moving the boundary.

An invented sizing calculation makes the interaction visible. Suppose the research worksheet allocates one hundred quote-currency units to the nominal entry-to-boundary distance, ignores costs for this illustration and permits quantities only in steps of one thousand base units. With distance 0.00054, the raw quotient is about 185,185.19 units. A downward quantity mapping gives 185,000 units and a nominal distance amount of 99.90. With distance 0.00053, the raw quotient is about 188,679.25; the mapped quantity is 188,000 and the nominal amount is 99.64.

Both mapped amounts are below the invented one-hundred-unit budget, but the quantities differ by three thousand units. The example does not recommend either exposure or claim that the nominal amount bounds an account’s loss. It shows that the price decision and quantity decision form a coupled calculation. A report that compares only the final nominal amount could overlook the changed exposure, while one that compares only quantity could overlook the changed distance.

Retain the intermediate values and the order of operations. Reversing the sequence, rounding the distance before it is defined, or using the displayed price rather than the specified calculation value can produce yet another result. The appropriate reference is the declared economic contract, with every approximation and omitted cost visible, not whichever sequence happens to produce a neat final quantity.

Grid metadata belongs to the instrument version

A study that records only a symbol name may be missing the information needed to reproduce its numerical decisions. The same familiar label can exist on different providers with different contract details, quote conventions or accepted precision. Metadata should be associated with the actual research environment and the period to which it applies.

If specifications change, preserve the applicable version or effective interval. Applying today’s grid retrospectively to an older archive can change which historical thresholds were considered valid. Conversely, carrying an old specification into a new adaptation can create unexplained rejections or silently altered boundaries.

Keep the rule version and the instrument specification together. The record should identify the source of the increment, the time it was retrieved or verified and the assumptions used when historical specifications are unavailable. A missing historical specification is a limitation to report, not a reason to invent precision from the prices that happened to appear in the sample.

Observed prices alone may under-identify the grid. A sample containing only whole values is compatible with several finer increments. Absence of a fractional price in that sample does not prove that the fraction is forbidden. The admissible set comes from the relevant specification, while the observed set is only what happened to occur.

The documentation-and-code version article explains why a reproducible package needs aligned descriptions and artifacts. Include numerical conventions in that alignment. Otherwise two implementations can faithfully follow the same verbal strategy while disagreeing at every boundary because they silently imported different instrument metadata.

A boundary table is more useful than many ordinary examples

A function can appear reliable on thousands of random interior values while failing at exact boundaries. Concentrate the documentary test set around the places where the decision changes: an exact tick, a value just below, a value just above, an exact midpoint, the smallest permitted value and a boundary where another constraint becomes active.

For a hypothetical increment of 0.00001 and a purchase ceiling policy, an exact 1.10003 should remain 1.10003. A value of 1.100039 should map to 1.10003, preserving the ceiling. A value of 1.100029 should map to 1.10002. A nearest policy would answer some cases differently, which is why the expected result must be tied to the rule rather than to a generic notion of numerical closeness.

Test properties as well as examples. The mapped value should lie on the declared grid. A ceiling-preserving purchase mapping should never exceed the raw ceiling. Applying the same mapping twice should leave an already mapped value unchanged. These properties help detect mistakes that a handful of favorable examples may miss.

Include scale and unit checks. Confusing a pip with a tick can shift the grid by a factor of ten or another instrument-specific ratio. A quantity field accidentally interpreted as a price may still be a valid decimal number while being economically meaningless. Types, labels and explicit units are part of the evidence, not merely programming decoration.

The expected answers should come from an independent hand calculation or a separately reasoned reference, not from copying the implementation’s output into a test file. The article on independent checks for AI-generated code develops that distinction. An AI can help enumerate boundaries, but its assertions still need to be checked against the declared mathematical contract.

Compare the decisions that changed, not only the final profit

When a rounding policy changes, a final equity difference is an incomplete diagnosis. Two implementations might finish close together while disagreeing on many entries whose effects cancel. Another pair might differ on one boundary that leads to a large path divergence. The comparison needs an event-level explanation.

Build a hypothetical audit table containing raw threshold, grid, mapping policy, mapped threshold and eligibility decision. Compare those rows across versions before comparing profit. For every changed decision, inspect the relevant quote side and timestamp. This separates a numerical-policy change from an unrelated data or execution-model change.

Do not choose the rounding policy because it produces the best backtest. That would turn a specification decision into another parameter search over historical outcomes. The policy should preserve an explicitly chosen meaning; its economic consequences then become evidence about that meaning. If several policies are legitimate alternatives, treat them as separate declared hypotheses rather than interchangeable implementation fixes.

In a hypothetical fixed-quantity calculation, one tick of 0.00001 across one hundred thousand base units is one quote-currency unit. Repeating an identical one-tick difference on 250 independent accounting entries would sum to 250 units before other effects. This arithmetic illustrates scale, not a forecast of savings or a claim that all affected events remain otherwise unchanged.

Discrete decisions can amplify a small numerical difference. A boundary change may alter whether a position exists, when an exit occurs or which later signal is feasible. A complete replay can therefore differ by much more than the direct price adjustment. Keep the simple monetary calculation as a diagnostic, then study the actual decision path under the declared model.

Consider a separate hypothetical path with a raw purchase ceiling of 1.100035 and an observed eligible ask of 1.10004. A nearest mapping to 1.10004 would classify that observation as eligible under an inclusive comparison. A ceiling-preserving mapping to 1.10003 would not. The price difference between the two mapped levels is one tick, but the difference between their records is presence or absence of a position, not merely one tick of cost on a shared position.

If the next observation moves favorably, the first model may show a gain that the second never had. If it moves adversely, the first may show a loss that the second avoided. Selecting the rounding convention after seeing that next observation introduces future information into what should have been a prior specification choice. A paired report should identify the changed eligibility first and describe later outcomes only as consequences under each declared model.

This is also why a tiny average quantization error can be misleading. Most thresholds may lie far from consequential quote boundaries, while a few lie exactly where classification changes. Alongside mean and maximum price adjustment, count changed decisions and inspect their timing. The distribution of decision effects can matter more than the average distance between raw and mapped numbers.

Negative values and special numbers need an explicit domain

Most ordinary spot-Forex quote examples use positive prices, but numerical helpers are often reused for distances, changes, profits or other signed values. On negative inputs, rounding toward zero is different from rounding toward negative infinity. A method casually named round down may therefore do something different from what a reader expects.

With a hypothetical integer grid, minus 1.2 rounded toward zero becomes minus one, while a mathematical floor becomes minus two. If the helper was written for positive prices, both methods appeared equivalent in ordinary tests. Reusing it for signed adjustments without defining the domain introduces a hidden change in meaning.

The safest research specification names the domain and behavior for invalid inputs. Missing values, non-finite numbers and a zero or negative increment are not ordinary prices awaiting a convenient rounded result. They should remain distinguishable from a valid zero-valued observation. Converting every problematic input to zero can create a valid-looking but nonsensical boundary.

A numerical error should not silently become an economic instruction. In a documentary study, the appropriate output may be an invalid-case record with the original input and reason. That preserves the evidence needed to correct the upstream calculation without pretending that an arbitrary replacement value was part of the strategy.

This domain discipline also helps with language and locale. A comma can denote a decimal separator in one context and a thousands separator in another. The research archive should retain an unambiguous representation and parse it under a declared convention. A displayed Spanish price and an English export can describe the same number, but only if their interpretation is explicit.

Make the translation reviewable before trusting the adaptation

A compact numerical specification should state the raw economic condition, instrument grid, rounding direction, tie policy where relevant, valid input domain and treatment of infeasible cases. It should also preserve the raw value alongside the mapped value, so a reviewer can see what changed during translation.

For an AI-assisted exercise, ask for a boundary table and a verbal explanation of each result. Require the assistant to distinguish display precision from tick size, show the preserved inequality and identify cases where no permitted value satisfies all constraints. Keep the exercise on archived or hypothetical values rather than granting an ambiguous numerical helper authority over an account.

The free TradeAndRoll demo supplies ten Forex systems, source material and original market CSVs for research. Numerical translation is a practical question to investigate when studying how a written rule becomes a reproducible model. A valid decimal is only useful when it preserves the intended decision. That understanding supports better testing; it does not guarantee execution, future returns or freedom from capital risk.

A hypothetical purchase-ceiling test table maps exact tick 1.10003 to itself, 1.100039 to 1.10003 and 1.100029 to 1.10002, checking grid membership and ceiling preservation
Independent expected answers make a numerical policy reviewable. The table tests the intended inequality, not merely whether a library returns a number.
Back to the Blog