From our research notebook

Why Closed-Bar Logic Matters

We explain why we often anchor a decision to a completed candle, and what we still need to define about timing, repeated events and higher timeframes.

Looking back at a chart is easier than making a decision while its latest candle is changing. In our EA work, that gap made candle timing a question we wanted to settle at the specification stage.

We choose the information the decision can use

When we use a completed candle, we give the EA a reading that can be revisited later. The open candle may cross a level several times before settling elsewhere. Acting during it can be intentional, but then we need to review the decision as it existed intrabar.

We also define how often the EA can act

Waiting for a close is not enough by itself. The first valid tick of a new candle needs a once-per-event rule, including after a restart. We apply the timing choice separately to higher timeframes, because a lower candle's close does not finish the higher one.

We keep the trade-off visible

Waiting introduces delay and can change the entry price. It cannot prevent gaps, slippage or an indicator revising older values. We choose a timing policy to match the method, then use the same policy in the test, the live logic and the later review.

Explore the technical detailOpen the full method, worked examples and implementation questions. We have kept this material here so you can follow the reasoning as far as you need.

A chart becomes visually final after the candle closes. During the candle, price and indicator values can cross, reverse, and disappear. If an EA acts on that moving state, its decision may not be visible in the same form later.

Six reviewed briefs explicitly referred to a new-bar or candle-close event. The repeated engineering need was a stable boundary: decide once, with information that can be reconstructed afterward.

Short answer · SHORT-03

When the EA makes its decision

An open candle can still change. The closed-candle path waits for the final bar, reads it once, and then sends a valid setup to the risk controls.

  1. 01
    Open candleValues may change on every tick and a visible state can disappear before close.
  2. 02
    Close eventThe candle receives a final time, price range, and indicator state for that bar.
  3. 03
    SnapshotThe EA reads the selected closed bars and records one synchronized decision.
  4. 04
    Next actionA valid setup proceeds to risk permission; an invalid one waits for another event.

What it solves

Closed-bar logic prevents the EA from treating a temporary intrabar cross as a final signal. It also makes historical and live decisions easier to compare because both can refer to the same completed bar.

It works best with an explicit one-decision-per-bar rule. Without that guard, the first tick of the new candle may still trigger repeated evaluation or duplicate orders after a restart.

What it does not solve

Waiting for the close introduces delay and may produce a worse entry. It does not prevent slippage, gaps, repainting of older history, bad data, or a weak strategy. It only fixes the information boundary used for the decision.

For higher timeframes, the policy must be stated separately. A lower candle can close while the current higher candle remains open. Reading higher bar zero at that moment is still intrabar logic.

A complete rule

A complete sentence looks more like this: on the first valid tick of a new lower-timeframe candle, read the last completed candle from every required timeframe, evaluate once, and ignore further ticks until the next permitted event.

The exact timeframes and conditions change by strategy. The value comes from saying when information becomes final and when the system is allowed to act.

Questions you may have

Does closed-bar logic prevent repainting?

It prevents acting on changes within the selected open bar. It cannot stop an indicator from recalculating older bars if that is how the indicator is designed.

Is closed-bar logic suitable for scalping?

Sometimes, but the delay may matter more. The choice should match the strategy horizon and be tested with realistic execution.

Separate candle close, observation time and order time

Scroll the diagram horizontally or open it at full size.

Separate candle close, observation time and order time
Educational design example — values and states are not live performance.

Illustrative server times · bar close, observation and dispatch are different events.

Open full diagram ↗

Separate candle close, observation time and order time

A candle has a scheduled end, but an EA normally learns that it ended when a later tick or timer event arrives. The price available for an order can be later again. Treating those moments as one timestamp hides delay.

Two constructed paths around a zero crossing
Path During 10:00–10:05 At scheduled close First observed / tradable Intrabar vs closed-bar result
Temporary cross +0.04 at 10:03, then −0.02 Value −0.02 at 10:05:00 Tick 10:05:02 at new price Intrabar: signal; closed bar: none
Persistent cross +0.04 at 10:03, +0.03 at close Value +0.03 at 10:05:00 Tick 10:05:02 at new price Both signal, but at different times and prices

Store last_processed_bar_time when the decision event is created, before trying to send an order. Store the request separately. If the terminal restarts before confirmation, reconcile order and deal history by the stable event/request ID; do not create another decision merely because no open position is visible yet.

Before confirmation: state is decided and request pending. After confirmation: state is decided and exposure confirmed. A restart in either state restores the same source-bar identity, then checks the account. One decision per bar is not the same promise as one filled order per bar.

What to verify

  • Replay a crossing that disappears and one that remains through close.
  • Log scheduled bar end, first observation time and executable quote separately.
  • Restart before and after confirmation and require no duplicate request.

Limits of this example

Closed-bar logic improves stability and reproducibility but adds observation and execution delay. Intrabar logic is valid when that trade-off is deliberate and tested with tick data.

Editorial ownership and primary references

Reviewed by POLARIS Research

Evidence scope

This is an educational design and validation analysis. It explains testable failure modes; it is not evidence that a strategy will be profitable.

Primary references

These references support platform behaviour or research concepts. They do not validate POLARIS performance and do not guarantee future results.

Explore the next relevant layer

Move between focused research, system engineering and portfolio construction without losing the context of this page.

Contact POLARIS on WhatsApp