OPEN-SOURCE SCRIPT

Morning ORB FVG Trigger

90
✅ Overview

Morning ORB FVG Trigger is a complete intraday trading framework built around:

A Morning Opening Range Breakout (ORB)

The first Fair Value Gap (FVG) after that breakout

Strict risk management and position sizing

Optional HTF trend filter (Daily / Weekly / Monthly)

Optional Daily ATR filter to avoid extreme days

The script is designed for futures / indices / FX on intraday charts up to 15 minutes and for traders who want a clean, mechanical entry framework with clear risk.

🧠 Core idea

Define a morning opening range (e.g. 09:30–09:45).

Wait for a clean breakout above/below that range.

After the breakout, wait for the first FVG in breakout direction,
confirmed by the next candle (no immediate full reclaim).

Use a chosen stop logic + R:R factor to build risk/reward boxes.

Calculate position size based on your account risk.

(Optional) Only take trades:

In the direction of the HTF EMA trend (D/W/M).

On days where the morning range is within a band of the Daily ATR.

You can also disable all signals/boxes and use the script just as a visual ORB tool.

⏰ 1. ORB / Morning Range

Inputs (Main section)

Morning Range Session
Time window of the opening range in exchange time
Example: 09:30–09:45 for a 15-minute ORB.
You can type custom ranges (e.g. 09:30–09:35 for a 5-minute ORB).

Risk/Reward (TP factor)
Multiplier for the take-profit distance relative to the stop.

2.0 = TP is 2× the stop distance

1.5 = TP is 1.5× the stop distance

Show ORB range
If enabled, draws:

ORB high/low lines

ORB labels (e.g. 15min ORB high / low)

Optional midline

Extend ORB lines to the right (bars)
How many bars to extend the ORB high/low horizontally beyond the ORB itself.

Trade box width (bars)
Horizontal width (in bars) of:

Red risk box (entry–stop)

Green reward box (entry–TP)

Implementation details

The ORB is always calculated on 1-minute data internally, so it stays precise even on 5m/15m charts.

The script only works on intraday timeframes up to 15 minutes.

📦 2. FVG Block

Group: “FVG”

Threshold %
Minimum size of an FVG in % of price.

0 = every FVG

Higher values = only larger gaps

Auto threshold (from volatility)
If enabled, the minimum FVG size is derived from historical volatility
instead of a fixed percentage.

Allow breakout FVG partly inside ORB

Off (default): the FVG must lie fully outside the ORB.

On: the breakout FVG itself may still overlap the ORB a bit,
as long as it is the first one attached to the breakout move.

Enable FVG entry signals, boxes & alerts

On: full system – FVG detection, entry labels, risk/TP boxes, alerts.

Off: no entries, no risk/TP boxes, no alerts.
You only get the ORB and (optionally) the HTF dashboard, so you can trade your own setups.

Entry mode

Entry mode (Mid / Edge / NextOpen)

Mid – Entry at the midpoint of the FVG.

Edge – Long at the upper FVG edge, short at the lower FVG edge.

NextOpen – No limit order in the gap. Entry is placed at the next bar open after FVG confirmation.

Edge offset (ticks)
Additional offset for Edge entries:

Long:

+ticks = a bit above the FVG (more conservative)

-ticks = deeper into the FVG (more aggressive)

Short:

+ticks = a bit below the FVG

-ticks = deeper into the FVG

FVG detection logic

Uses a LuxAlgo-style 3-candle FVG pattern (gap between candle 1 and 3).

Only one FVG is taken: the first valid FVG after the ORB breakout in breakup direction.

The FVG candle is the middle bar; the script:

Detects the FVG on the previous bar.

Waits for the current bar to confirm it:

Bullish: current low must stay above the lower FVG boundary

Bearish: current high must stay below the upper FVG boundary

Only then an entry signal is generated.

🛑 3. Stop Logic

Group: “Stop Logic”

Stop mode (PrevBar / Pivot / FVG Candle)

PrevBar – Stop at the low/high of the candle before the FVG
(tight/aggressive).

FVG Candle – Stop at the low/high of the FVG candle itself
(medium).

Pivot – Stop at the most recent swing high/low
using pivotLeft / pivotRight pivots (more conservative).

Ticks (stop buffer)
Offset (in ticks) from the selected stop level.

> 0 = further away (more room, more risk)

< 0 = closer (tighter stop)

Pivot left / Pivot right
Number of candles left/right to define a swing high/low
when using Pivot stop mode.
Typical intraday values: 2–3.

The script also sanity-checks the stop:
if the calculated stop would be invalid (e.g. above entry in a long), it moves it by a minimal distance (2 ticks) to keep a valid risk.

📈 4. HTF Trend Filter (Daily / Weekly / Monthly)

Group: “HTF Trend Filter”

Enable HTF trend filter
If enabled, trades are only allowed:

Long when at least 2 of D/W/M closes are above their EMA

Short when at least 2 of D/W/M closes are below their EMA

EMA length (D/W/M)
EMA length for all three higher timeframes (Daily, Weekly, Monthly).

This helps focus entries in the direction of the dominant higher-timeframe trend.

📊 5. ATR Filter (Daily)

Group: “ATR Filter (Daily)”

Use daily ATR filter
If enabled, the height of the ORB (ORB high – ORB low) must be within
a band of the Daily ATR to allow any signals.

Daily ATR length
ATR period on the Daily timeframe.

Min ORB size vs ATR
Lower bound:

Example: 0.3 → ORB must be at least 0.3 × Daily ATR

0.0 = no minimum.

Max ORB size vs ATR
Upper bound:

Example: 1.5 → ORB must be ≤ 1.5 × Daily ATR

0.0 = no maximum.

If the ORB is too small (choppy) or too large (exhausted move), no breakout or FVG signal will be generated on that day.

🧭 6. HTF Dashboard & Signal Labels

Group: “HTF Trend Dashboard”

Show HTF dashboard
Draws a small label at the top of the chart showing:
HTF Trend (EMA X)
D: UP/FLAT/DOWN
W: UP/FLAT/DOWN
M: UP/FLAT/DOWN

Dashboard position

Top Right, Top Center, Top Left – places the dashboard at the top.

Over Risk Info – no top dashboard; instead, the HTF trend info is shown as a label near the risk box when a new signal appears.

Lookback (bars) for top anchor
How many bars to use to determine the top price level for dashboard placement.

Show HTF trend above risk box on signal
Only relevant if Dashboard position = Over Risk Info.
When enabled, a small HTF label appears near the risk box for each new trade.

Signal label vertical offset (ticks)
Vertical spacing between risk info label and HTF label.

Minimum spacing HTF/Risk (ticks)
Ensures a minimum vertical distance so the two labels don’t overlap.

HTF signal label X offset (bars)
Horizontal offset (left/right) relative to the risk info label.

⏳ 7. ORB–FVG Filters (Session & Time Window)

Group: “ORB FVG Filter”

Only same session day
If enabled, FVG entries are only allowed on the same calendar day
as the ORB. When the date changes, all state & drawings are reset.

Limit hours after ORB
Enables a time window after the ORB end.

Trading window after ORB (hours)
Length of that window in hours.
Example: 2.0 → FVG signals only in the first 2 hours after ORB end.

💰 8. Risk Management & Position Sizing

Group: “Risk Management”

Calculate position size
If enabled, the script computes suggested mini and micro contract size for you.

Account size
Your trading account size (in account currency).

Risk mode

Percent – risk is a % of account size (Account risk %).

Fixed amount – risk is a fixed dollar amount (Fixed risk ($)).

Account risk %
Risk per trade as a percentage of account size (e.g. 1.0 for 1%).

Fixed risk ($)
Fixed risk per trade in dollars when using Fixed amount mode.

Micro factor (vs mini)
How much a micro contract is worth relative to a mini.
Example:

0.1 → one micro moves 1/10 of one mini.

Risk Info label

For each new trade, a label is shown above the boxes with:

Stop distance in price and $ risk per mini

Max risk allowed for the trade

Suggested mini and micro size

Text like:

Suggested: 2 mini

Suggested: 5 micro

or Suggested: no trade

This makes the script especially useful for prop-firm rules or strict risk discipline.

🎨 9. Visual Style (Boxes, Labels, ORB Lines)

Group: “Box & Label Style (Trade)”

Label font size (Very small, Small, Normal, Large)

Entry label BG / text color

Stop label BG / text color

TP label BG / text color

Risk info BG / text color

Risk box color (entry–stop zone)

Reward box color (entry–TP zone)

Group: “ORB Style”

ORB high line color

ORB low line color

ORB line width

ORB label font size

ORB label background color

ORB label text color

Show ORB midline

ORB midline color / width / style (Solid / Dashed / Dotted)

⚠️ 10. Alerts

Group: “Alerts”

The script defines three alert conditions:

Long entry FVG breakout
Triggered when a new long signal appears.

Short entry FVG breakout
Triggered when a new short signal appears.

FVG entry (long/short)
Generic alert for any new signal (long or short).

To use them:

Add the indicator to the chart.

Open the Alerts dialog → “Condition”.

Select this script and one of the alert conditions.

Set your preferred expiration and notification settings.

Alerts only fire when Enable FVG entry signals, boxes & alerts is on.

🧩 11. How the trading logic flows (summary)

Build ORB on 1-minute data during the selected session.

Optionally reject the day if ORB is outside the ATR bounds.

Wait for a breakout (close above high or below low), respecting HTF trend filter.

After breakout, look for the first valid FVG in that direction:

Outside the ORB (unless breakout FVG allowed inside)

Confirmed by the next candle (no full reclaim)

Once confirmed:

Compute entry, stop, target.

Draw risk/reward boxes and all labels.

Optionally show HTF signal label over the risk info.

Trigger alerts if enabled.

If you disable FVG signals, only steps 1–3 (plus dashboard) are effectively active.

⚠️ 12. Notes & Disclaimer

Script is intended for intraday trading up to 15-minute timeframes.

All signals are mechanical and do not guarantee profitability.

Always backtest and forward-test on your own data before risking real money.

This script is for educational purposes only and is not financial advice.

🚀 Quick-start guide

Add the script to your chart

Use an intraday timeframe ≤ 15 minutes (1m, 3m, 5m, 15m).

Works best on liquid indices, futures, FX and large-cap stocks.

Set the Morning Range

In “Morning Range Session” choose the exchange’s opening window.

Examples

US index futures (CME): 08:30–08:45 or 08:30–08:35

US stocks (NYSE/Nasdaq): 09:30–09:45 or 09:30–09:35

The ORB is always calculated on 1-minute data internally, so the range stays accurate on higher intraday charts.

Keep the default filters at first

HTF Trend Filter: ON

EMA length = 20

This will only allow trades in the direction of the dominant D/W/M trend.

ATR Filter: OFF (optional; you can enable later once you’re comfortable).

Use the full trade system

In the FVG group leave

“Enable FVG entry signals, boxes & alerts” = ON

Entry mode: Mid

Stop mode: FVG Candle or PrevBar

Risk/Reward: 2.0 as a starting point.

Set your risk

Turn on “Calculate position size”.

Enter your Account size and choose either:

Risk mode = Percent (e.g. 1.0 = 1% per trade), or

Risk mode = Fixed amount (e.g. $250 per trade).

The risk info label will show:

Stop distance in price and $/contract

Max allowed risk

Suggested mini and micro contract size.

Enable alerts (optional)

Open the Alerts dialog → Condition: this script.

Choose one of:

Long entry FVG breakout

Short entry FVG breakout

FVG entry (long/short)

Choose “Once per bar” or “Once per bar close”, and your preferred notification type.

Replay & journal

Use the TradingView bar replay tool to step through past days.

Focus on:

How the ORB defines the structure.

How the first confirmed FVG outside the ORB behaves.

Whether the risk/TP levels fit your own style and product.

🎛 Recommended settings & profiles

These are starting points, not rules. Always adapt to the instrument and your own risk tolerance.

1. Conservative / Trend-following

Timeframe: 5m or 15m

Morning Range Session: 15-minute ORB around the cash or futures open

FVG

Threshold %: 0.05–0.1 (filter out very small gaps)

Auto threshold: OFF (keep it simple)

Allow breakout FVG partly inside ORB: OFF

Enable FVG entry signals/boxes/alerts: ON

Entry mode: Mid

Stop Logic

Stop mode: Pivot

Pivot left/right: 2–3

Stop buffer: +1–2 ticks

HTF Trend Filter

Enabled: ON

EMA length: 20

ATR Filter

Enabled: ON

Daily ATR length: 14

Min ORB vs ATR: 0.3–0.4

Max ORB vs ATR: 1.2–1.5

Risk Management

Risk mode: Percent

Account risk: 0.5–1.0%

Idea: Only trade when the higher-timeframe trend supports the move and the opening range is of a “normal” size for the current volatility.

2. Balanced / Intraday directional

Timeframe: 3m or 5m

FVG

Threshold %: 0.02–0.05

Auto threshold: ON (lets the script adapt to volatility)

Allow breakout FVG partly inside ORB: ON
(first breakout FVG may partly sit inside the ORB)

Entry mode: Edge

Edge offset (ticks): 0 or +1

Stop Logic

Stop mode: FVG Candle

Stop buffer: 0–1 ticks

HTF Trend Filter

Enabled: ON

ATR Filter

Enabled: OFF (optional)

Risk Management

Risk mode: Percent

Account risk: 1.0–1.5% (if this fits your plan)

Idea: Slightly more aggressive entries at the gap edge, still aligned with HTF trend, but with more flexibility on ATR.

3. Aggressive / Scalping around the ORB

Timeframe: 1m or 3m

FVG

Threshold %: 0.0–0.02

Auto threshold: ON

Allow breakout FVG partly inside ORB: ON

Entry mode: NextOpen or Edge with a negative offset (deeper into the gap)

Stop Logic

Stop mode: PrevBar

Stop buffer: 0 or -1 tick

HTF Trend Filter

Enabled: OFF (or ON but treat as soft guidance)

ATR Filter

Enabled: OFF

Risk Management

Risk mode: Percent

Account risk: lower, e.g. 0.25–0.5% per trade

Idea: More trades and tighter stops. Best for experienced traders who understand the limitations of scalping and whipsaw risk.

Final reminder

All of these are templates, not guarantees:

Always check how the system behaves on your market and session.

Start on replay and demo before trading real money.

Adjust filters (HTF, ATR, thresholds) until the signals fit your personal approach.

Exención de responsabilidad

La información y las publicaciones no pretenden ser, ni constituyen, asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.