OPEN-SOURCE SCRIPT

SwiftEdge Opening Range

493
SwiftEdge Opening Range tracks the opening range of up to four fully configurable sessions at once (New York, London, Asia and a custom session by default). It classifies every breakout as held or failed and measures how each session's breakouts have behaved on the chart's history. The goal is to answer, for your own symbol and timeframe, which session's opening range is worth trading, and whether to trade the breakout or the fake-out.

WHAT IT SHOWS

• Opening range per session
The high and low of the first N minutes of each session, drawn as a box while it forms and as a shaded band with high/low lines through the rest of the session. A mid line, optional inner levels (for example 0.25 and 0.75 of the range) and extension levels (multiples of the range, 1× and 2× by default) can be added. Each session has its own name, time window, range length (1 to 480 minutes) and colour, and can be drawn on the chart or only counted in the statistics.

• Breakouts
A breakout is the first bar of the session that closes beyond the range. An optional buffer (in ATR) and an optional relative-volume filter can be required. Breakouts are marked with a small dot in the session's colour.

• Held vs fake-out
After a breakout, the script watches a fake-out window (6 bars by default). If a bar closes back inside the range within that window, the breakout is classed as a fake-out and marked with ×. If not, it is classed as held.

• Breakout playbook (fully configurable)
– Entry: on the breakout bar's close, with a stop order at the range edge (filled the moment price trades through it), or on a retest of the broken edge within a set number of bars.
– Stop: opposite side of the range, range mid, ATR multiple, range multiple, or beyond the breakout bar.
– Targets: target 1 and an optional target 2. Each can be an R multiple, an ATR multiple, a range extension, points, a percentage, or the session end. You choose the share closed at target 1, and the rest runs to target 2.
– Exit management: break-even after target 1 or at a chosen R, an ATR- or range-based trailing stop (always or only after target 1), a maximum holding time, and an optional exit when the breakout turns into a fake-out.
– Presets: Classic (close entry, opposite-side stop, 2R), Retest (limit on the broken edge, mid stop, 50% at 1R, rest at 3R), Momentum (stop order, 1 ATR stop, 50% at 1.5 ATR, rest trailed by 1.5 ATR) and Range targets (50% at 1× extension, rest at 2×). Custom uses your own settings.

• Fade playbook
On a fake-out, enter in the opposite direction on the close that confirms it. The stop goes just beyond the breakout extreme or at an ATR distance. The target is the opposite side of the range, the range mid, an R multiple, an ATR multiple, a range extension, points or a percentage.

Commission and slippage are deducted from every trade, and open trades are closed at the session end. Intrabar fills (stop orders, retests, stops and targets) are simulated from each bar's high and low. When a stop and a target could both have been hit in the same bar, the stop is assumed first, and an entry-bar stop is counted as a loss. Trades are drawn like position tools: a risk box and a target box from entry to exit (with a dotted line at target 1 when a partial exit is used) and the result in R next to it.

• Panel (sessions side by side)
– Today: status (forming, waiting, broke, held, fake-out, in trade) and today's range size in ATR, with its percentile against past sessions.
– Breakout rate: share of sessions with a breakout, and the up/down split.
– Held / fake-out: how breakouts resolved.
– Reached 1× extension: share of breakouts that travelled at least one full range beyond the opening range.
– Held · narrow / wide range: held rate for sessions whose range was below vs above the median range size. This shows whether small opening ranges break out more cleanly on your market.
– Breakout trades and fade trades: number of trades, win rate and average result in R, plus how often target 1 was reached. These are repeated for the last part of the history only (out-of-sample, 30% by default) so you can see whether the result is stable.

HOW IT WORKS

1. A session starts on the first bar inside its session window. The range is built from all bars that open within the first N minutes.
2. The range is complete on the first bar that opens after those N minutes. That bar is already checked for a breakout.
3. Breakouts, fake-outs, entries and exits are evaluated only on closed bars, so nothing on the chart changes after a bar closes.
4. Stops and targets are checked against each bar's high and low. If both could have been hit in the same bar, the stop is assumed first. Gaps through a level fill at the open.
5. Range sizes are measured in ATR(14) so sessions and markets can be compared.

HOW TO USE IT

• Pick the sessions you trade and set their times in the timezone input (New York time by default).
• Read the panel before the session: a high breakout rate with a high held rate favours the breakout playbook, while a high fake-out rate favours fading.
• Use today's range percentile together with the narrow/wide row to judge whether today's range is the kind that has tended to hold.
• Compare the full-history and out-of-sample rows. A playbook that only works in the older part of the data is unlikely to be robust.
• Use a chart timeframe at or below the opening-range length (for example 5m for a 30-minute range).

SETTINGS

Sessions (enable, name, time window, range length, colour, draw or statistics only), breakout buffer, relative-volume filter, fake-out window, both playbooks (stops, targets, exit on fake-out, break-even), costs, out-of-sample share, and display options: range box, band, high/low, mid, inner levels, extension levels, level labels (current session, all or off), session title, marks, trades and results, last N sessions or today only, transparencies and colours. The panel position and text size can also be changed.

LIMITATIONS

• Results are simulated on the loaded history and depend on the settings, the data feed and the chart timeframe. They are a measurement, not a forecast, and not a complete trading system.
• Session times are fixed clock times in the chosen timezone. Markets with irregular hours, holidays or half days can produce partial sessions.
• On timeframes longer than the opening range, the range is formed by a single bar and the results become less meaningful.
• Relative volume needs volume data from the feed.

This script is for analysis and education. It does not provide trading advice, and past behaviour shown on the chart does not imply future results.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。