A breakout starts with a properly defined range
Define a timed range, confirm a breakout and reconstruct orders, exits and costs through a complete hypothetical EUR/USD example.

At half past eight, two programmers draw a line on the same chart. One includes the candle that starts at that time; the other ends the range just before it. When the price rises, the first programmer is still moving the line and the second is already waiting for a breakout. Both say they implemented “buy above the high of the first half hour”. They have built different decisions before sending a single order.
The disagreement cannot be resolved by choosing a more sophisticated indicator. It requires specifying which observations belong to the range, when they become available and which event permits action. A range is a rule for selecting information. Its high and low follow from that rule; they are not points that can be chosen after looking at the rest of the session.
We will follow an invented EUR/USD session, defining one pip as 0.0001 and buying 10,000 EUR. Every price, time and cost in the example is hypothetical. They describe neither Atlas trades nor a commercial robot’s results, and they provide no estimate of profitability. The sequence ends in a loss because that makes it possible to check how an apparently small definition changes risk and accounting.
The practical objective is for someone else to reconstruct every decision without asking what we meant by “break”, “close” or “enter again”. A breakout rule is complete when it also explains its awkward cases. Exact touches, gaps and delayed responses are part of the rule.
1. Choose the interval that the range represents
We begin with a fixed window between 08:00:00 and 08:30:00 UTC. The starting boundary is included and the ending boundary is excluded: an observation corresponding to exactly 08:30:00 belongs to the subsequent period. Saying that the window has finished means that its duration has elapsed; it does not mean that both mathematical boundaries are inclusive. This distinction prevents an everyday word from changing which data we select.
We use thirty one-minute candles identified by their starting times, from 08:00 through 08:29. The range comes from their bid highs and lows. We do not use the candle starting at 08:30, even if an interface draws it beside the marker delimiting the half hour. We also distinguish thirty records from thirty minutes: a duplicated record does not replace a missing minute.
A moving window covering the previous thirty minutes would define another strategy. Old observations could leave as new ones arrive; the breakout level might fall even if the current price barely changed. A fixed window instead preserves its extremes throughout the subsequent decision period. Neither has a logical claim to superiority, but comparing them requires recognising that they ask different questions about the price.
The pandas documentation makes boundary inclusion explicit through the closed argument for rolling windows. Its default includes the right boundary. That library convention does not determine which window our strategy needs. Official rolling reference.
Describe the set of observations first, then translate it into the chosen tool. For this exercise, an explicit selection by time may be clearer than a rolling calculation. Time boundaries are strategy parameters, even when they do not appear among an indicator’s visible controls. Changing them after observing a trade means changing the rule that produced that trade.
2. Give the clock and each candle a meaning
Using UTC in this exercise removes the need to convert a local opening time, but does not make the clock irrelevant. We must distinguish event time, receipt time and decision time. A candle whose interval ends at 08:30 may reach the program a fraction of a second later. The robot cannot use its final contents before receiving them.
In OANDA’s candle representation, the time field identifies the start; bid, ask and midpoint have separate components, and a flag identifies a complete candle. These are that provider’s definitions and need to be inspected when interpreting its data. Official candle schema.
In our sequence, the final range candle arrives complete at 08:30:00.200. Until that moment, construction continues. If someone retrospectively assigns the final high to 08:30:00.000, they give the program information two hundred milliseconds early. The difference might leave some sessions unchanged, but its irrelevance should not be assumed in a system specifically looking for movements near a boundary.
If the intended window followed a local civil time, we would need to name the relevant time zone and preserve the conversion rules used. IANA maintains a time zone database incorporating historical changes in offsets and daylight saving rules. An ambiguous abbreviation or a fixed offset assumed for every date would not be enough. IANA Time Zone Database.
Our design does not claim that 08:00 UTC always coincides with the opening of any particular market. These are simply the coordinates chosen for a demonstration. The displayed time does not establish availability. To reproduce the decision, we also preserve when the candle was received and when it passed the minimum integrity checks. If those fields are unavailable, a historical study can declare a latency assumption, but cannot present that assumption as a measurement of what happened live.
3. Construct, check and freeze the extremes
Suppose the thirty valid candles have an overall bid high of 1.1020 and bid low of 1.1000. The width is 0.0020, equivalent to twenty pips. We add a fixed two-pip buffer above the high for entry, giving an upper threshold of 1.1022. We also set an exit reference two pips below the low, at 1.0998.
These numbers define our teaching version. The buffer is not a discovery about how much noise EUR/USD contains, and the width does not forecast how far the price will subsequently travel. A construction formula is not a forecast. We are merely converting past observations from an already defined interval into levels that a rule will use later.
When the final candle arrives, we check for all thirty expected starting times, without duplicates and with the necessary price components. If any candle is missing at 08:30:02.000, this exercise cancels entry for the session. That two-second deadline is a declared operational choice, not a recommended tolerance for every system. We wait before the deadline; afterwards, we do not silently complete the range with late data.
Once the range is accepted, we save a session identifier, the observations used and both extremes. The range is frozen. If a high of 1.1040 appears at 08:40, it does not replace the construction high. Nor do we use the full day’s high, downloaded after the session ends, to decide what would have happened at 08:32. That substitution introduces information which did not yet exist.
Freezing does not mean erasing later provider corrections. If a revision arrives, we can retain it as another data version for an audit. However, reconstructing the original decision requires the version that was actually available. Mixing the two can produce a visually tidy history while destroying the explanation for why the robot acted as it did.
4. Decide which side of the quote must break
Our main rule is long only: the bid close of a complete one-minute candle must be strictly above 1.1022. We choose bid both to construct the high and to observe the breakout. Any resulting purchase is modelled using the ask side and its later execution. This separation lets us discuss signal and cost precisely.
An upward breakout does not always have to be defined this way. We could compare ask with an ask high, or midpoint with a midpoint high. A rule comparing ask against a bid high would also be possible, but it would need to acknowledge that the spread participates directly in activation. Switching sides without saying so changes the event being detected.
Imagine a bid of 1.1021 and an ask of 1.1024. The ask is above the 1.1022 threshold while the bid remains below it. Our version has no confirmed breakout. If bid stays unchanged and only ask rises, an ask-based rule could activate because the spread widened. That would not demonstrate an equivalent advance in bid, nor establish a single economic cause for the change.
A short-selling variant would require a fresh specification of the construction, confirmation and execution sides. Inverting a sign while retaining every reference is insufficient. A sale executed against bid and a buying exit observed on ask need their own sequence. Symmetry in a drawing does not ensure symmetry in operation.
Signals and executions have different prices. OANDA documents activation conditions by price component and distinguishes them from the component used for execution. This is specific API behaviour, not a guarantee applying to every intermediary. Official order definitions. Our example uses that conceptual distinction without claiming that its entire decision process can be transferred directly into a native order.
5. Resolve equality, touches and precision
At 08:30:20 we observe bid at 1.1022 and ask at 1.1024. Bid exactly matches the threshold. A strict greater-than condition returns false; an inclusive condition would return true. No mathematical interpretation makes those answers equivalent. Wording such as “when price reaches the level” often conceals precisely this decision.
In the main version, an intraminute quote is also insufficient: we need the complete close. That touch therefore fails two independent requirements, strict superiority and confirmation over time. Keeping both reasons helps explain the outcome. If we changed only the equality criterion, we would still have no closing signal at that moment.
At 08:30:42, bid reaches 1.1023 and ask reaches 1.1025. We now have an observation strictly above the threshold, but continue waiting. The candle starting at 08:30 ends with a bid close of 1.1021. A strategy responding to the first quote above the threshold could have acted; ours does not. The same path contains an intraminute breakout and an absence of confirmation at the close.
Touching, exceeding and confirming are different events. A numerical tolerance should not be improvised to turn a touch into an exceedance. If the computer representation can introduce small rounding discrepancies, integer price units consistent with the declared precision or decimal arithmetic can preserve the intended comparison. The result should reflect the written threshold, rather than an accidental calculation residue.
We express prices to four decimal places here for clarity; we are not claiming that this is the only precision a platform supports. If a provider uses finer increments, the design must preserve the appropriate ones. Rounding before evaluation could turn 1.10221 into 1.1022, removing a genuine exceedance under the original precision.
Equality is decided before examining which extra trades it would have admitted. An inclusive version can legitimately be studied, but should retain its own name and result history. Retrospectively choosing between touching and exceeding according to what suits each session creates a strategy that no single rule could have executed.
6. Waiting for the close has a time cost
The candle starting at 08:31 ends at 08:32 with bid at 1.1024 and ask at 1.1026. Its bid close is above 1.1022. We receive the complete candle at 08:32:00.180, which is when the buying decision becomes possible. We do not assign execution to the 1.1024 close: that is a bid observation belonging to the interval that has just finished.
The program sends its request at 08:32:00.220. At that instant, the hypothetical quote is bid 1.1025 and ask 1.1027. It subsequently receives a full execution of 10,000 EUR at 1.1028, occurring at 08:32:00.260. We assume comparable clocks and sufficient information to order these events. The eighty milliseconds between receipt and execution are not an estimated latency for any service.
The distance from the confirmation bid to the purchase is four pips. Two correspond to the difference between bid and ask at the close; one corresponds to the ask change between close and submission; another corresponds to the difference between the ask observed at submission and execution. This is an accounting decomposition: it does not independently identify what caused each movement.
Close confirmation removes signals caused by excursions which disappear before the candle ends, as happened in our first minute. It also delays the decision and can move the entry price further from the range. Neither effect demonstrates an improvement in economic results. In some sessions, waiting avoids an entry; in others, it delays participation in a favourable move.
The close is information, not a promise of execution. Comparing immediate and confirmed versions requires execution models consistent with their respective decision times. Giving the confirmed version the price of an earlier quote turns a comparison of rules into an artificial advantage. The article on slippage reference prices develops the reference question further.
7. Specify what happens when the price jumps
A breakout does not require every intermediate price to appear in the record. In a variation on our session, imagine that the last observation is 1.1021 and the next is 1.1035. We have not observed a touch at 1.1022. Nevertheless, a level condition can be true at the second observation. A rule requiring an exact observation of the threshold would behave differently.
We should not fill the gap by drawing a trajectory and declaring a purchase at 1.1022. A chart may connect points to make them easier to read; its line adds neither quotes nor available counterparties. For the confirmed rule, we still have to wait for the complete candle and evaluate its close. An intraminute jump that retreats before the close may produce no entry.
Our main version sets a maximum acceptable buying price of 1.1030. If the order cannot execute in full within that bound under the assumed mechanism, the attempt ends without a purchase. The main case’s execution at 1.1028 satisfies the restriction. In the variant with available prices above 1.1030, we do not invent an execution at the bound.
OANDA’s documentation includes a priceBound field for certain market orders. Its existence illustrates a specific price restriction; order types and their conditions need verification in each integration. Definition of priceBound. Here, the 1.1030 bound belongs to our simulation and does not guarantee an execution.
A price bound can turn a signal into a trade that never happens. That outcome must remain in the record. Examining only executed purchases loses precisely the cases where the distance control changed behaviour. Evaluating the rule requires knowing how many signals failed to become entries and what information existed when they were rejected, without treating them as profits or losses that actually materialised.
8. Separate signals, requests, positions and exhausted sessions
A price comparison alone does not describe a robot. Our session moves through construction, ready, entry pending, position open, exit pending and finished. It can also end as invalid because of incomplete data, or exhausted because its entry attempt was rejected. Each state determines which messages are accepted and which actions remain permitted.
Buying is prohibited during construction. Once the range is frozen, the session is ready and considers only confirmation from subsequent candles. The first valid signal permits a single entry request for that session. A pending request is not a position. Until its response is known, we assume neither a purchased quantity nor a price, and we do not gain permission to submit another entry.
For simplicity, the teaching case uses a request which executes completely or opens no position. An integration permitting partial executions needs additional states for executed and pending quantities, plus rules to protect the open portion. It would be misleading to describe that extension as already solved by our example with one full execution.
An expired waiting period does not establish rejection either. An execution could exist while its notification has yet to arrive. Recovery must query or reconcile the identified request before considering a retry. Our version permits no second entry request, but it still has to establish whether a position exists and requires an exit.
After closing the purchase, we do not enter again in the same session. Another close above the threshold does not reset the counter. If there is no signal, entry eligibility expires at 09:00 UTC; a decision received at exactly that time is already excluded. If a position still exists, the rule requests a timed exit and waits for execution, rather than pretending the position disappears when the clock changes.
The next range belongs to another predefined session using new data. Restarting the program does not create a new session. Preserving the identifier, the used attempt and pending requests prevents a reconnection from turning a single-entry strategy into repeated entries. A computer restart and a reset of the trading logic are different events.
If expiry arrives while an entry remains pending, we request cancellation and reconcile the response. We do not assume that cancellation wins a race against an execution already under way. A purchase confirmed after expiry requires the corresponding timed exit; it cannot be discarded from the record because it arrived late. This case explains why the finished state can only represent a session with neither an open position nor requests still awaiting clarification.
9. Follow the exit through to the actual result
Our position opens at 1.1028. The exit trigger remains bid less than or equal to 1.0998; equality is included here because we explicitly chose that condition for protection. We do not automatically carry over the entry’s strict comparison. Nor do we wait for a candle close for this exit: we observe available quotes while holding the position.
At 08:47:10, a quote arrives with bid at 1.0997 and ask at 1.0999. This is the first observation activating the exit in the invented sequence. The sale subsequently executes at 1.0996. The 1.0998 level was not a guaranteed execution price. The adverse difference between purchase and sale is 0.0032, equivalent to thirty-two pips.
With 10,000 EUR, each pip of 0.0001 USD per EUR is worth one dollar. The price difference produces minus 32 USD. We add a hypothetical total round-trip commission of 1 USD and obtain minus 33 USD. There is no financing or currency conversion in this invented accounting. If either existed, it would require its own amounts and dates.
The spread is already reflected in the execution prices. We do not deduct another two spread pips from the thirty-two-pip loss: that would count part of the cost twice. The distance can be decomposed to understand it, but the sum of its components must reconcile with the difference between executions and the commissions added separately.
There are twenty-six pips between the 1.1024 confirmation bid and the 1.0998 threshold. The later purchase adds four adverse pips, and the exit below the threshold adds two. That brings us to thirty-two before commission. This identity explains an invented trade; it does not estimate a typical loss. An exit threshold defines an action, not a universal ceiling on losses. Execution, gaps and quantity still matter.
10. Connect width, buffer and size without confusing them
The range measures twenty pips, but the distance between our actual purchase and the exit threshold is thirty. The upper buffer, the wait for confirmation and the executed price explain why exposure does not match range width. Sizing the position on the assumption of twenty pips to the protective exit would have described a different risk from the one eventually taken.
We retain 10,000 EUR in this exercise to keep the calculation readable. We do not propose that size for a real account. A version adjusting quantity according to distance from the exit would need to decide when that distance is established. Using the executed price to choose the quantity of that same order retrospectively relies on an outcome which was not known at submission.
A preliminary quantity could be calculated using the submission quote, with an allowance for adverse execution within the permitted bound. That would be another explicit policy. Once execution arrived, the record would show both intended and resulting exposure. If quantity needed reducing, that reduction would be a new action with its own cost, rather than a free correction of the past.
We could also study buffers proportional to width. A ten-percent buffer equals two pips here because the range measures twenty. For a forty-pip range, it would produce four. Two rules coinciding in our session does not make them equivalent: their difference emerges precisely when range width changes.
Width organises distances; it does not demonstrate opportunity. A narrow range can produce many crossings of a nearby level, while a wide range can leave the entry price far from the exit. These are consequences of the chosen geometry, not sufficient arguments for declaring which produces better trades. If ranges that are too small or too large are excluded, the boundaries and reasons for exclusion must be written before reviewing their outcomes.
11. Treat defective data as events
Now suppose the 08:17 candle is missing. The other twenty-nine show the same extremes as our example, but that does not prove the absent minute contained no more distant high or low. Filling it with the last known close would invent an observation. Our integrity rule cancels the session if the data fails to arrive before the established deadline.
A duplicate creates another problem. Two records with the same time do not represent two minutes. Identical records can be recognised as the same observation; conflicting ones require a version policy. Automatically choosing whichever widens the range most, or improves the eventual result, introduces a preference absent from the original definition.
Messages can also arrive out of order. An old candle received after freezing must not silently reopen construction. It is useful to record the late data, preserve the original decision and, where appropriate, produce a clearly identified alternative reconstruction. The difference between those reconstructions provides information about process quality; it is not a reason to erase the first one.
Not observing a price is different from observing that it never occurred. If we retain only closes, we can check entry confirmation but cannot reconstruct the first intraminute exit crossing with certainty. If we have only a candle’s high and low, the order in which they occurred may be missing. A trade depending on that order requires a more detailed record or an explicitly unresolved conclusion.
Data provenance must accompany the range: provider, instrument, price component, granularity and receipt rules. We do not claim that one provider’s high represents every tradable price in the market. Replacing the source can alter the extremes without any coding error. Before deciding that two implementations disagree, we must establish whether they received the same set of observations.
12. Replay the session one event at a time
A useful reconstruction starts empty and adds information in the order it became available. At 08:30:00.200 it accepts the range and saves 1.1020, 1.1000, 1.1022 and 1.0998. It does not buy on the 08:30:20 touch or on the 08:30:42 intraminute exceedance. On learning the close at 08:31, it checks 1.1021 and remains ready.
When the next complete candle arrives at 08:32:00.180, the reconstruction records one signal and moves to entry pending. It preserves the 08:32:00.220 request separately from the 08:32:00.260 execution. From then on, it ignores new entry signals and evaluates the exit condition on bid. The exit following the 08:47:10 observation ends the position without enabling another purchase.
This sequence lets us compare two implementations by their decisions before comparing aggregate results. If one buys on the touch and another on the close, the disagreement is already located. If both signal at the same time but use different prices, we inspect execution. A single final profit or loss number would conceal these differences in meaning.
The most informative check changes one event. We can replace the 1.1024 close with 1.1022: equality removes the signal. We can delay the final range candle beyond 08:30:02.000: the session becomes invalid. We can raise the only executable price above 1.1030: the purchase does not happen under the assumed price restriction.
Other cases check persistence: repeating an execution notification must not duplicate the position; restarting after consuming the attempt must not permit another entry. These checks do not forecast profitability, but they do examine the particular breakout contract. The minimum record preserves the received event, previous state, evaluated condition, emitted action and resulting state, with enough identifiers to connect requests and responses.
13. Record versions before comparing them
We have identified several choices that could vary: fixed or moving range, bid or ask, strict or inclusive exceedance, immediate quote or close, fixed or proportional buffer, and one entry or several. If everything changes together, a difference in results does not reveal which choice produced it. Comparison requires readable versions with bounded changes and a specific question.
We can call our strict bid-close rule A, a rule using the first bid quote strictly above the threshold B, and an inclusive bid-close rule C. For that comparison, all three would share the window, exit, size and cost treatment. B could act at 08:30:42; A would wait for our second candle; C would differ from A when a close exactly matched the threshold.
Recording those versions before inspecting results protects interpretation. A new idea can still be studied later, but it is recorded as new. A selection made after examining many alternatives should not be presented as the only rule originally proposed. The number of choices examined also helps explain how much scope there was for selection.
Comparing versions requires retaining the trades that never happened. A rule may improve the average of its executed purchases merely by excluding different sessions. We need to examine shared sessions, differences in signals, attempts that did not execute and the costs associated with each path. The question cannot be reduced to which version displays the highest average.
No breakout is universally better by definition. API documentation establishes how fields are interpreted, not which rule will make money. Our example establishes arithmetic consistency under invented assumptions, not historical evidence. A study using real observations would have to identify its sample, source and actual results. Keeping these three kinds of claim separate allows a discussion of design without turning it into a commercial promise.
14. Deliver a rule someone else can challenge
At the end, we should be able to describe the main version without relying on the chart: thirty complete one-minute bid candles, from 08:00 inclusive to 08:30 exclusive, in UTC; acceptance after receipt, with a deadline of 08:30:02.000; frozen high and low; a two-pip buffer; confirmation by a bid close strictly above the threshold; one attempt before 09:00.
The description continues with a hypothetical purchase of 10,000 EUR, a 1.1030 price bound, an exit when bid is less than or equal to 1.0998 and a timed exit if a position still exists at 09:00. The absence of a profit target is another choice in this version. An opposite signal does not open a short, and no further breakout reactivates the session after its attempt has been consumed.
Readers can question any of these choices. They may prefer another window, a proportional buffer or a confirmed exit. That discussion is now productive because each change has a meaning and a place where its consequences can be examined. Writing a specification is not about shielding it from criticism; it makes criticism point to a reproducible decision.
A complete rule explains why it did not trade. If it cannot distinguish missing confirmation, absent data, an expired session, a consumed attempt and a price restriction, it still leaves some behaviour open to interpretation. That gap matters as much as the formula for the high.
To apply this way of reading to concrete material, consult the TradeAndRoll demo and begin by identifying windows, prices and states in the available documentation. This article’s figures and diagrams are an independent exercise; they neither describe the offered robots’ rules nor establish their results.
Sources
- OANDA: candle definitions, for timestamp meaning and price components.
- OANDA: order definitions, for activation conditions and price bounds specific to its API.
- pandas: DataFrame.rolling, for temporal boundary inclusion.
- IANA: Time Zone Database, for the provenance and updating of time zone rules.



