A breakout trading strategy enters when price leaves a defined range, such as the highest high of the prior N bars or a session's opening range. A complete breakout rule states four things: how the range is built, what counts as leaving it, whether a touch or a bar close confirms it, and where the stop goes. False breakouts and fills beyond the level are the two costs every version has to survive.

This page is part of PineConnector's trading strategy library. Breakouts are the entry most trend following rules use; this page covers the entry itself. Every rule below is an illustrative example to test, not a recommendation.
Breakout trading strategy at a glance
Scroll horizontally to read every column.
| Decision | Common choices | What to write down |
|---|---|---|
| Range | Prior N-bar high and low; opening range of a session; a prior day's high and low | Lookback, bars included, session times and time zone |
| Trigger | Price trades beyond the level; or a bar closes beyond it | Touch or close, and any buffer beyond the level |
| Order | Pending stop order at the level; or market order after the close | Order type and what happens if it never fills |
| Filters | Minimum range width, time window, spread limit | Each filter as a separate measurable condition |
| Stop and exit | Opposite side of the range; a trailing or time exit | Initial risk R and the exit rule |
How do you define the range?
Donchian channel breakout. Richard Donchian's channel uses the highest high and lowest low of a set number of periods; TradingView's help page shows a 20-day example.[1] For a breakout test, use the prior N bars and exclude the bar being tested. In Pine Script v6, ta.highest(high, n) includes the current bar, so the prior-range value is ta.highest(high, n)[1].[12][16]
Long breakout = close > highest high of the prior N bars
Opening range breakout. The range is the high and low of the first part of a session, for example its first 60 minutes. The rule needs the session's start time, its length and the time zone that defines them. TradingView session strings encode start time, end time and optional days. The time() function interprets a session in the exchange's time zone "unless a timezone argument is specified", which can differ from the chart's.[3]
Clocks are where opening range rules break most quietly. A London open written in UTC shifts by an hour when UK clocks change, and a broker's MT5 server time can follow yet another offset. Read broker server time versus UTC and TradingView time and the forex market sessions guide before fixing the times.
Prior day's high or low. A level from a completed day is final at that day's close. A level from a swing point confirmed later by pivot logic is not, as the support and resistance rules page explains.
Should a breakout trigger on a touch or a bar close?
The trigger choice changes the entry price, the number of false breakouts taken and how the rule maps to orders.
- Intrabar touch with a stop order. A buy stop sits above the range. The CFTC defines a stop order as one that "becomes a market order when a particular price level is reached".[7] MetaQuotes adds that a triggered stop is executed at the specified price "or worse", so a fast move fills with slippage.[8] Every poke above the level is filled, including those that reverse within the bar.
- Bar-close confirmation. The rule waits for a close beyond the level, then enters. Bars that poke through and close back inside are skipped. The entry is later and usually further from the level, so the initial risk to a range-based stop is larger.
Bollinger's rules note that "Closes outside the Bollinger Bands are initially continuation signals, not reversal signals."[2] That is a reading of closes, not touches, and it is the opposite of the mean reversion reading of the same event. Which reading a market supports is what a test decides.
Worked example: an opening range breakout, two ways
Illustrative values, not a recommendation. A 60-minute opening range on EURUSD has a high of 1.10500 and a low of 1.10100: 40 pips wide. One PineConnector pip on a five-decimal quote is 0.00010.[9]
| Step | Stop order, 1 pip above the high | Close confirmation |
|---|---|---|
| Planned entry | 1.10510 | First close above 1.10500, say 1.10620 |
| Initial stop | 1.10110, 40 pips below entry = 1R | 1.10110, 51 pips below entry |
| Fill | Fast move fills at 1.10550: 4 pips of slippage | Market order near the close, subject to spread and slippage |
| Risk to stop at fill | 44 pips = 1.1 × planned R | 51 pips before slippage |
| A bar pokes to 1.10530 and closes at 1.10450 | Filled, now inside the range | Not entered |
The 4 pips of slippage cost 4 ÷ 40 = 0.1R before the trade has moved. The close version avoided the false breakout in the last row but paid 11 more pips of entry distance (1.10620 − 1.10510) whenever the breakout holds. Neither is shown to be the better rule; the example shows what each one trades away.

Why do breakouts fill worse than the level?
A breakout order is, by design, bought when price is rising through a level. Several effects push the fill away from the chart level:
- Stop orders become market orders. The fill is the next available price once triggered, which can be beyond the level.[8]
- Gaps. In TradingView's emulator, when price gaps past a pending order's level between bars, the order fills "at the opening price of the bar following the gap".[4] Broker stops can also fill past a gap; see weekend gaps at the market open.
- Chart price versus execution price. TradingView's help notes that FOREX.com charts on TradingView are based on mid-price, while execution "takes place strictly according to Ask/Bid".[14] TradingView and MetaTrader can also use different feeds.[13] A chart touch is not proof the broker's Ask reached the level.
- Backtests understate it. TradingView calls slippage "dynamic and unpredictable" and suggests a fixed amount per order in tests.[4] The slippage guide covers how to model it.
How does a breakout rule map to TradingView alerts and MT5 orders?
Alerts trigger only on realtime bars. With the once-per-bar-close frequency, alert() fires only when the realtime bar closes, which suits a close-confirmed rule.[5] A touch rule instead needs either an intrabar alert or a pending order placed ahead of time. TradingView's repainting guide shows barstate.isconfirmed as one way to require a confirmed bar.[6]
Illustrative sketch; not compiled or tested. Checked against the Pine Script v6 reference as of 25 September 2026.[12]
//@version=6
indicator("Prior-range breakout sketch", overlay = true)
n = input.int(20, "Lookback bars")
upper = ta.highest(high, n)[1]
lower = ta.lowest(low, n)[1]
longBreak = barstate.isconfirmed and close > upper
shortBreak = barstate.isconfirmed and close < lower
plot(upper)
plot(lower)
alertcondition(longBreak, "Close above prior range", "Close above prior N-bar high")
alertcondition(shortBreak, "Close below prior range", "Close below prior N-bar low")
The sketch only creates alert conditions; the alert and its frequency are set in TradingView's alert dialog. It does not handle an existing position, a repeat signal or the stop.
Verify on a demo account first. PineConnector's demo testing guide says a successful demo order verifies the tested setup, not that the strategy will be profitable.[11] Choose your own symbol, size and rules. Illustrative messages for the TradingView alert's Message field, not an instruction to trade:
LicenseID,buystop,EURUSD,vol_lots=0.01,entry_price=1.10510,sl_pips=40
LicenseID,cancellong,EURUSD
The first requests a 0.01-lot buy stop at 1.10510. PineConnector's pending commands reference lists buystop for buying above market and measures pending stop distances from the pending entry, so the stop is requested at 1.10510 − 40 × 0.00010 = 1.10110.[9] The entry price must sit on the correct side of the market and meet the broker's tick size and minimum distance. The second, sent at the end of the window, cancels the symbol's pending buy stops and buy limits; it does not close an open position.[15]
A close-confirmed rule sends a market buy instead. PineConnector's spread= parameter sets a maximum spread at arrival for entries; passing it is not a confirmed order.[10] In either case, the alert triggering, webhook delivery, PineConnector processing, the EA's order request and the broker's fill are separate events, each with its own evidence.
What makes breakout rules fail?
- False breakouts. Price leaves the range and returns. A touch trigger takes all of them; a close trigger takes fewer but not none. Tighter buffers mean more fills and more reversals.
- Undefined ranges. “The morning range” without a time zone, or a range that includes the signal bar, gives a different rule from the one tested.
- Stale pending orders. A buy stop left in place after the window can fill hours later in a different market. State when unfilled orders are cancelled.
- Tuned filters. Each filter added after looking at the chart fits the history more closely. TradingView warns an overfit strategy "often fails to perform well on new, unseen data".[4]
- Costs in narrow ranges. A small range means a small R, so spread and slippage are a larger share of it.
Frequently asked questions
What is an opening range breakout?
An opening range breakout enters when price moves beyond the high or low set during the first part of a session, such as the first 60 minutes. The rule must state the session start, the range length and the time zone. Clock changes and broker server time can shift the range if the time zone is left implicit.
How does a Donchian channel breakout work?
A Donchian channel breakout enters long when price closes above the highest high of the prior N bars, or short below the lowest low. Richard Donchian created the channel; TradingView's help uses a 20-day example. Exclude the current bar from the range, and state whether a touch or a close triggers the entry.
What is a false breakout?
A false breakout is a move beyond a range's high or low that returns inside the range soon afterwards. A stop-order entry is filled on every false breakout that reaches its level. Requiring a bar close beyond the level skips some, at the cost of a later entry and a larger distance to a range-based stop.
Why does my breakout order fill above the level?
A breakout buy stop becomes a market order once triggered, so it fills at the next available price, which can be above the level in a fast move or a gap. Chart prices can also differ from the broker's Ask and Bid. Include slippage in backtests and check actual fills on a demo account.
Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account and no code was compiled.
Related reading
- Algorithmic trading strategies: the strategy library
- Trend following rules, profile and alert mapping
- Market, limit and stop orders
- Broker server time vs UTC vs TradingView
- Confirmed-bar evaluation in Pine Script
Sources
- TradingView Help Center – Donchian Channels (DC), accessed 25 September 2026.
- John Bollinger – Bollinger Bands Rules, accessed 25 September 2026.
- TradingView – Pine Script User Manual: Sessions, accessed 25 September 2026.
- TradingView – Pine Script User Manual: Strategies, accessed 25 September 2026.
- TradingView – Pine Script User Manual: Alerts, accessed 25 September 2026.
- TradingView – Pine Script User Manual: Repainting, accessed 25 September 2026.
- CFTC – Futures Glossary: Stop Order, accessed 25 September 2026.
- MetaQuotes – MetaTrader 5 Help: Executing Trades, placing stop orders, accessed 25 September 2026.
- PineConnector – Syntax: pending commands and PineConnector pip, accessed 25 September 2026.
- PineConnector – Syntax: spread=, accessed 25 September 2026.
- PineConnector – Demo testing: test an active setup on a broker demo account, accessed 25 September 2026.
- TradingView – Pine Script v6 reference: ta.highest, ta.lowest, barstate.isconfirmed, alertcondition, accessed 25 September 2026.
- PineConnector – Frequently asked questions: price differences, accessed 25 September 2026.
- TradingView Help Center – Why was my order executed or not executed although the price on the chart reached the order level?, accessed 25 September 2026.
- PineConnector – Syntax: cancel pending orders, accessed 25 September 2026.
- TradingView – Pine Script User Manual: Execution model, accessed 25 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.