Home / Learn / TradingView Broker Emulator: Intrabar Or
Backtesting Basics

TradingView Broker Emulator: Intrabar Order Assumptions and What Bar Magnifier Changes

How the broker emulator sequences OHLC price within a bar to fill stops and limits—and what actually changes when you switch to Bar Magnifier.

What the Broker Emulator Actually Is

TradingView's strategy tester does not connect to a real exchange. It uses an internal module called the broker emulator—a rules-based execution engine that decides when each order in your strategy gets filled based solely on the price data the chart has available. The emulator handles market orders, limit orders, stop orders, and stop-limit orders, applying them against each bar's OHLCV data in turn. It is what makes automated backtesting possible, and its behavior is determined entirely by what assumptions it makes about price movement inside each bar.

Understanding the broker emulator is distinct from understanding the three calculation modes (Close, On Every Tick, Bar Magnifier). The emulator is active in all three modes. What differs between modes is the intrabar price data the emulator receives to work with—synthesized, interpolated, or drawn from real lower-timeframe candles. The assumptions matter because a single OHLCV bar gives you four price levels but tells you nothing about the order in which they were visited.

The Intrabar OHLC Sequence Assumption

When you run a strategy in On Every Tick mode, the broker emulator constructs a simulated intrabar price path from each bar's OHLC values and applies a fixed sequence: on a rising bar (close greater than open), it assumes price moved open → high → low → close. On a falling bar (close less than open), it assumes open → low → high → close. This means a stop-loss placed below the open on a rising bar is assumed to trigger after the high is already reached—a sequence that the actual market may never have produced in that order.

The practical effect is that stop and limit orders positioned inside the bar's range get fills that are plausible but model-derived, not observed. For wide-range bars with tight stops, the assumed sequence can produce fill outcomes that differ meaningfully from what a live execution would have delivered. This is an acknowledged limitation of backtesting from OHLCV bars rather than tick data, and TradingView documents it. The issue is that many traders do not realize the assumed path is as specific—and as consequential—as it is.

The gap is widest when intrabar volatility is large relative to your stop or target distance. If your stop is narrow and the bar's range is several multiples wider, the order in which the high and low were visited within that bar can determine whether your trade is a winner or a loser. Under the fixed-sequence assumption, the emulator will give you a consistent answer—just not necessarily the correct one.

What Bar Magnifier Does Differently

Bar Magnifier replaces the fixed open → high → low → close assumption with actual lower-timeframe OHLCV candles. If your chart runs on a 4-Hour timeframe, Bar Magnifier may load 15-minute or 1-hour sub-bars and replay your strategy's orders against those real candles. Because the sub-bars are drawn from actual historical data, the intrabar path is no longer a model—it reflects how price sequenced during that period.

The improvement is real but bounded. Each sub-bar is still OHLCV data: it has the same four-price, one-sequence problem the top-level bar had. The difference is that sub-bars are smaller, so the gap between the assumed sequence and actual tick-by-tick movement is narrower. For strategies that execute at bar close on 4-Hour or Daily charts with wide stops, Bar Magnifier rarely changes results dramatically—the intrabar path only matters when your stops and limits fall inside the bar's range. For strategies with tight intrabar targets, the effect is larger.

One concrete signal to watch for: if switching from On Every Tick to Bar Magnifier meaningfully worsens your results, that is not a defect in Bar Magnifier—it is evidence that the On Every Tick sequence assumption was quietly inflating your fills. Bar Magnifier is slower to compute and does not eliminate all execution uncertainty, but it is the most accurate option available when intrabar path sequencing matters to your strategy.

Pivot Confirmation and Look-Ahead Bias

A separate but related issue arises with indicators that use pivot points, support and resistance levels, or any calculation that is not confirmed until the bar closes. In Pine Script, a pivot high or pivot low requires a certain number of subsequent bars before it can be identified—the value is undefined until those confirmation bars have printed. If your strategy fires orders based on a pivot that has not yet confirmed, it is using future information to make a present decision. The broker emulator will fill those orders correctly given the data it receives; the error sits upstream, in what data the signal calculation is allowed to see.

The standard fix is barstate.isconfirmed: wrapping signal logic inside this condition ensures your strategy only fires orders on fully closed bars. This eliminates the class of look-ahead errors that come from acting on unconfirmed candle or pivot data. This is mechanically distinct from the intrabar fill-sequence problem—it is not about how the broker emulator prices a fill, but about which bars' data your signal is permitted to use. Both problems inflate backtest results; they operate through separate mechanisms and require separate fixes. Changing calculation mode from On Every Tick to Bar Magnifier does not resolve a look-ahead error in the signal logic.

These Are Hypothetical Backtests, Not Advice

Everything described here applies to hypothetical backtests, not live trading. All results on this site reflect what would have happened historically under a fixed set of rules and cost assumptions—they are not financial advice, not a recommendation to trade any strategy, and not a prediction of future performance. Past backtest performance does not guarantee future results under any conditions.

Across 660,005 backtests on 903 assets—tested on 1-Hour, 4-Hour, Daily, and Weekly timeframes with realistic round-trip costs—only 26% of indicator and asset combinations beat a simple buy-and-hold strategy. Getting the execution model right is not about making your results look better. It is about understanding what your results mean before you risk capital. The broker emulator's intrabar assumptions, when applied conservatively, contribute to that number being modest rather than inflated.

FAQ

Questions, answered

What OHLC sequence does TradingView's broker emulator use?

In On Every Tick mode, the broker emulator assumes a bullish bar (close greater than open) moves in the sequence open → high → low → close, and a bearish bar (close less than open) moves open → low → high → close. This determines the order in which stop and limit orders placed inside the bar's range are triggered. Bar Magnifier replaces this assumed sequence with actual lower-timeframe candles, which is more accurate but still subject to the same OHLCV sequencing limitation at the sub-bar level.

When does the intrabar assumption matter most?

It matters most when your strategy places stop or limit orders inside a bar's range—when the target or stop price sits between the bar's open and close, and the outcome depends on the order in which those price levels were visited. For strategies that execute at bar close on Daily or Weekly charts with wide stops, the assumption rarely changes results significantly. For strategies with tight intrabar execution where bar range is large relative to target distance, it can be the difference between a plausible result and an impossible one.

Does Bar Magnifier fix look-ahead bias from pivot calculations?

No. Bar Magnifier addresses how intrabar fills are sequenced—it replaces the assumed OHLC path with real lower-timeframe data. It does not fix look-ahead errors in signal calculations. If your strategy's entry signal uses a pivot that is not confirmed at the time the signal fires, Bar Magnifier fills that order correctly given what it receives, but the signal itself was based on future information. That requires a code fix—using <code>barstate.isconfirmed</code> or the <code>[1]</code> history reference operator—not a change to calculation mode.

Are the backtests on this site financial advice?

No. All results are hypothetical backtests run under fixed assumptions, including realistic round-trip costs. They show what would have happened historically—not what will happen in the future, and not a recommendation to trade any strategy. Past backtest performance does not guarantee future results under any conditions.

Honest by default

Every figure here comes from our own out-of-sample backtests, costs included — not a course or a guess. Educational information only — not investment advice. Hypothetical backtested results; past performance does not guarantee future results. Trading involves risk of loss.

Keep reading

Free · no spam

Get the weekly edge report

The best-performing indicator per asset, what changed this week, and the honest caveats — straight to your inbox.