TradingView Strategy Fills at Next Bar Open, Not the Close
Pine strategies signal on the close but fill at the next open. See what process_orders_on_close changes and why 'On order fill' fakes exact-high exits.

The signal candle closed at 100.00. Your strategy tester says the long entered at 100.60. You check the code, find no bug, and start wondering whether the platform is cheating you. It is not. A TradingView strategy that signals on a bar's c
The signal candle closed at 100.00. Your strategy tester says the long entered at 100.60. You check the code, find no bug, and start wondering whether the platform is cheating you.
It is not. A TradingView strategy that signals on a bar's close cannot fill on that close by default, so the earliest fill is the next bar's open, and whatever gap sits between the two prices becomes your entry.
The default is one tick of delay, and it lands on the next open
TradingView's Pine Script manual is plain about the default. Unless you change it, a strategy executes once per closed bar, on history and on live bars alike. If the current bar is still open, the strategy waits.
On top of that, every order gets a one-tick delay. The manual's reasoning is that creating and filling an order on the same tick is unrealistic. Put the two defaults together and the earliest tick an order can fill on is the open of the following bar.
The manual's own walkthrough shows it. When the entry condition is true on bar 20, the script places an order that fills at the open of bar 21. The exit condition fires when the script updates at the close of bar 21, and that exit fills at the open of bar 22. Entries and exits each sit one bar to the right of the signal that caused them.
If your chart markers look "late" compared with the signal you plotted, this is why. The markers are correct. Your mental picture of filling on the signal candle's close is the thing the emulator refuses to simulate.
A close and the next open are two different prices
Most of the time the gap between them is small. Around news, after a weekend, or on a thin instrument, it is not.
Here is a made-up example to show the arithmetic, not a measured result. A breakout rule signals when a candle closes at 100.00, with a planned stop at 99.00. That is 1.00 of risk, and a 2R target (twice the risk) sits at 102.00.
The next bar opens at 100.60. The emulator fills there. Your stop is still at 99.00, so the real risk is 1.60, which is 60% more than you planned. The 102.00 target is now only 1.40 away, so the reward-to-risk drops from 2.0 to 0.875.
The platform did not move your stop or shrink your target. Your plan was written for a price you could not get, and the backtest quietly enforced that. That is the honest outcome, and it is the same thing a live market order does at 9:30 after an overnight gap.
For price-based orders there is a second rule worth knowing. The manual says that if the market crosses a stop or limit level during the gap between one bar's close and the next bar's open, the emulator assumes no intrabar data exists in that gap. It fills at the next bar's opening price, not at the level you specified. A stop that "should" have filled at 99.00 can fill at 98.40 if the bar opens there. We covered the live-market version in why your stop order didn't fill where you set it.
process_orders_on_close removes the delay, and that is not always the realistic choice
Setting process_orders_on_close = true in the strategy() declaration lets the emulator fill an order created on a closing tick on that same tick. The same switch exists without touching code: TradingView's broker emulator help page lists an "Order execution delay" setting with two values, None and One tick.
The manual gives two legitimate uses. One is backtesting a manual approach where you exit just before the market closes. The other is using order fill alerts to try to trigger real orders before the next session starts.
That second use comes with a warning from the manual itself. Alerts still fire after the session closes, so in non-continuous markets a real order triggered by such an alert might not fill until after the market opens again. The simulated fill at the close price never existed for you.
One more detail from the manual: the setting does not change orders a strategy places before a bar's closing tick. Orders created on ticks inside a bar still fill on the next available tick.
The "On order fill" setting can fake exits at the exact high
This is the setting that does real damage to backtests, and it hides in a checkbox.
The calc_on_order_fills parameter (shown as "On order fill" in the Script execution settings) makes the script run an extra time on each tick where an order fills. It can be useful for strategies that act mid-bar, because the position size and average price update right away.
The catch, per the manual's lookahead bias section: on historical bars, the high, low, close and volume variables already hold the bar's final values during those extra runs. If your order logic reads them, the script is using data that would not exist yet on the opening tick in live trading.
The manual's demonstration is blunt. A long entry is created at the close and fills at the next open. The fill triggers the extra execution, and the script then sets a take-profit at the current bar's high. On most historical entries the trade exits at the bar's exact high. The manual calls that misleading, because knowing a bar's exact high at its open is impossible in real trading.
— The Tradoki desk noteIf a backtest sells the exact top of a candle again and again, you are not looking at skill. You are looking at a script that read the end of the bar from its first tick.
TradingView says the strategy report typically shows a warning banner when "On order fill" is active. If you see that banner and your exits cluster at the highs, stop and find the line of code that reads the current bar's range. The manual's suggested alternative is the "On history bar tick" setting, which updates those variables tick by tick on historical bars so the script cannot see the final values early.
This is a sibling of the higher-timeframe leak we describe in why a TradingView backtest looks perfect and fails live. Different mechanism, same smell: results that are too clean.
Live bars and history bars do not run the same code path
Run a strategy with calc_on_every_tick = true and the manual shows what happens. On historical bars the script places at most one order per bar, and each fills at the next bar's open. On realtime bars it can place several orders per bar, and the emulator fills most of them before the next bar opens, because every update on a live bar is a valid tick for filling.
Then you refresh the chart. The bars that were realtime become historical, and the script now places one order per closed bar on that stretch. Same code, same bars, different trades. The manual warns that changing these execution settings can repaint the strategy's calculations and results for exactly this reason.
So a strategy tested on closed bars only, and then forward tested live with tick execution switched on, is not the strategy you tested. For another place where TradingView's tools show less than people assume, see the data limits of bar replay.
Five checks before you trust an entry price
None of this makes the strategy tester broken. It makes the settings part of the strategy.
Open the list of trades and compare 10 entries to the chart. Is each entry price the open of the bar after the signal? If it is the signal bar's close, someone turned the delay off.
Read the strategy() line. Look for process_orders_on_close, calc_on_every_tick, calc_on_order_fills and calc_on_every_history_tick. Any of them set to true changes when and at what price orders fill.
Look for the report banner. An active "On order fill" setting normally triggers a warning at the bottom of the strategy report.
Add slippage on market and stop orders. The broker emulator's slippage field adds ticks to the fill price of those order types, which is the cheapest way to stop the backtest from assuming the best possible fill.
Re-run after any Pine version change. Behavior shifts between versions can alter results without a compile error, as we showed with the v6 breaking changes.
● FAQ
- Why does my TradingView strategy enter on the next candle instead of the signal candle?
- By default a strategy calculates once per closed bar, and every order it creates has a one-tick delay. The earliest tick it can fill on is the open of the following bar, so a signal on bar 20 fills at the open of bar 21. TradingView's Pine manual describes this as the default because creating and filling an order on the same tick is unrealistic.
- What does process_orders_on_close do in Pine Script?
- Set to true, it lets the broker emulator fill an order on the same closing tick where the script created it, instead of at the next bar's open. It only affects orders created on a bar's closing tick. The Order execution delay dropdown in the strategy properties does the same job without touching the code.
- Is the 'On order fill' setting safe for backtesting?
- Not without care. TradingView's manual warns it can create lookahead bias on historical bars, because the high, low and close variables already hold the bar's final values during the extra executions. Its own example exits trades at the exact high of the bar, which no live trader can reproduce. The manual points to 'On history bar tick' as the setting that avoids that form of bias.
- Why do my strategy's trades change after I refresh the chart?
- Realtime bars and historical bars execute differently when a strategy runs on every tick. After a refresh, bars that were realtime become historical, and the script places one order per closed bar instead of several per bar. The manual also notes that changing these execution settings can repaint the strategy's results.
Three more from the log.

Pine Script Limits: 64 Plots, 40 Requests, 500 ms Loops
Your script ran fine yesterday and now throws a limit error. Here are the Pine Script caps that bite traders: plots, request calls, loops, buffers, orders.
Nov 27, 2026 · 7 min
Pine Script v6 Breaking Changes: 5/2 Now Returns 2.5
v5 to v6 compiles clean but changes your results: 5/2 now returns 2.5, and/or short-circuit, and default margin flips from 0% to 100%.
Sep 07, 2026 · 8 min
Why your TradingView strategy tester lies to you
Your equity curve looks perfect because a broker emulator guessed the inside of every candle. The documented assumptions that inflate a backtest.
Aug 12, 2026 · 9 min