OPEN-SOURCE SCRIPT
ที่อัปเดต: ORB AM/PM Range

ORB — Opening Range Breakout
What does this indicator do?
Think of it like setting a tripwire on the market. Every trading day, the market opens and establishes a range during the first minutes — this is the Opening Range.
ORB watches two windows for you, records the highest and lowest prices within each, and then tells you the moment price breaks out of those levels. That breakout is often the start of a directional move — and that's when you want to pay attention.
Getting Started
Set the Timezone to match your chart's timezone.
What You'll See on the Chart
During the session windows: A teal shaded box appears during the AM session, growing in real-time as the high and low develop. An orange shaded box does the same during the PM session.
After each session ends: Dashed horizontal lines extend to the right from the final High and Low — these are your breakout levels. Price labels appear showing the exact High and Low values.
When price breaks out from the range: A teal triangle (▲ or ▼) appears if price crosses an AM level. An orange triangle (▲ or ▼) appears if price crosses a PM level. These triangles only appear during the valid time window — you won't see stale signals from yesterday's range, and AM signals disappear once the PM session begins.
Settings Explained
Timezone
Enable AM Session
AM Session Start
AM Session End
Enable PM Session
PM Session Start
PM Session End
Tip: The time format is simple — just write hours and minutes together. 900 = 09:00, 1345 = 13:45, 1600 = 16:00.
Important: The AM session must end before the PM session starts. If you enter overlapping times, the indicator will show a red error banner at the top of the chart and stop working until you fix it.
When Do Alerts Actually Fire?
This is the most important thing to understand. The indicator is not just checking "did price cross a level?" — it also checks when the cross happens:
09:00 09:30 15:30 16:00 │ AM Box │ AM alerts are valid │ PM Box │ PM alerts are valid │████████│◄─────────────────────────────►│████████│◄─────────────────────► EOD
AM alerts only fire between AM End and PM Start (same day). Once the PM session begins, AM signals shut off.
PM alerts only fire after PM End until the end of the trading day.
Nothing carries over to the next day. Yesterday's levels won't trigger today's alerts.
This means you only get signals when they're fresh and relevant.
Setting Up Alerts in TradingView
Right-click on the chart → Add Alert (or press Alt+A).
Under "Condition", select the ORB30 indicator.
Choose one of these conditions:
ORB Above AM High
- Price broke above the morning range — potential bullish breakout
ORB Below AM Low
- Price broke below the morning range — potential bearish breakout
ORB Above PM High
- Price broke above the closing range — bullish
ORB Below PM Low
- Price broke below the closing range — bearish
Any Range Cross
- Any of the above — good as a catch-all notification
Set your notification method (popup, email, webhook, etc.) and click Create.
The alert messages automatically include the ticker symbol and timeframe.
Common Scenarios
"I only trade the morning breakout"
→ Uncheck Enable PM Session. Only AM range boxes, lines, and alerts will appear.
"I trade US markets from Europe"
→ Set Timezone to America/New_York or UTC-5, then adjust the times. For NYSE, try AM Start 930, AM End 1000, PM Start 1530, PM End 1600.
"The dashed lines are too short / too long"
→ Adjust Extend levels (bars). Shorter timeframes need more bars to cover the same time span.
"I see a red error banner"
→ Your session times are invalid. Check that: (1) each Start is before its End, and (2) AM End doesn't overlap with PM Start.
"I don't see any triangles / alerts"
→ Make sure price actually crossed the level during the valid window. If the cross happened during the session itself or after hours, it won't count — by design.
Quick Reference
Teal box
-AM range being built
Orange box
-PM range being built
Teal dashed line
-AM High or Low level
Orange dashed line
-PM High or Low level
ORBA▲
-Breakout above AM High
ORBA▼
-Breakdown below AM Low
ORBP▲
-Breakout above PM High
ORBP▼
-Breakdown below PM LowPine Script®
What does this indicator do?
Think of it like setting a tripwire on the market. Every trading day, the market opens and establishes a range during the first minutes — this is the Opening Range.
ORB watches two windows for you, records the highest and lowest prices within each, and then tells you the moment price breaks out of those levels. That breakout is often the start of a directional move — and that's when you want to pay attention.
Getting Started
Set the Timezone to match your chart's timezone.
What You'll See on the Chart
During the session windows: A teal shaded box appears during the AM session, growing in real-time as the high and low develop. An orange shaded box does the same during the PM session.
After each session ends: Dashed horizontal lines extend to the right from the final High and Low — these are your breakout levels. Price labels appear showing the exact High and Low values.
When price breaks out from the range: A teal triangle (▲ or ▼) appears if price crosses an AM level. An orange triangle (▲ or ▼) appears if price crosses a PM level. These triangles only appear during the valid time window — you won't see stale signals from yesterday's range, and AM signals disappear once the PM session begins.
Settings Explained
Timezone
- UTC+1
- All session times are interpreted in this timezone. Make sure it matches your exchange.
Enable AM Session
- On
- Turn this off if you only care about the closing range. Everything AM-related disappears.
AM Session Start
- 900
- When the morning range starts. Enter in HHMM format — so 900 means 09:00.
AM Session End
- 930
- When the morning range locks in. 930 = 09:30.
Enable PM Session
- On
- Turn this off if you only care about the opening range. Everything PM-related disappears.
PM Session Start
- 1530
- When the closing range starts. 1530 = 15:30.
PM Session End
- 1600
- When the closing range locks in. 1600 = 16:00.
Tip: The time format is simple — just write hours and minutes together. 900 = 09:00, 1345 = 13:45, 1600 = 16:00.
Important: The AM session must end before the PM session starts. If you enter overlapping times, the indicator will show a red error banner at the top of the chart and stop working until you fix it.
When Do Alerts Actually Fire?
This is the most important thing to understand. The indicator is not just checking "did price cross a level?" — it also checks when the cross happens:
09:00 09:30 15:30 16:00 │ AM Box │ AM alerts are valid │ PM Box │ PM alerts are valid │████████│◄─────────────────────────────►│████████│◄─────────────────────► EOD
AM alerts only fire between AM End and PM Start (same day). Once the PM session begins, AM signals shut off.
PM alerts only fire after PM End until the end of the trading day.
Nothing carries over to the next day. Yesterday's levels won't trigger today's alerts.
This means you only get signals when they're fresh and relevant.
Setting Up Alerts in TradingView
Right-click on the chart → Add Alert (or press Alt+A).
Under "Condition", select the ORB30 indicator.
Choose one of these conditions:
ORB Above AM High
- Price broke above the morning range — potential bullish breakout
ORB Below AM Low
- Price broke below the morning range — potential bearish breakout
ORB Above PM High
- Price broke above the closing range — bullish
ORB Below PM Low
- Price broke below the closing range — bearish
Any Range Cross
- Any of the above — good as a catch-all notification
Set your notification method (popup, email, webhook, etc.) and click Create.
The alert messages automatically include the ticker symbol and timeframe.
Common Scenarios
"I only trade the morning breakout"
→ Uncheck Enable PM Session. Only AM range boxes, lines, and alerts will appear.
"I trade US markets from Europe"
→ Set Timezone to America/New_York or UTC-5, then adjust the times. For NYSE, try AM Start 930, AM End 1000, PM Start 1530, PM End 1600.
"The dashed lines are too short / too long"
→ Adjust Extend levels (bars). Shorter timeframes need more bars to cover the same time span.
"I see a red error banner"
→ Your session times are invalid. Check that: (1) each Start is before its End, and (2) AM End doesn't overlap with PM Start.
"I don't see any triangles / alerts"
→ Make sure price actually crossed the level during the valid window. If the cross happened during the session itself or after hours, it won't count — by design.
Quick Reference
Teal box
-AM range being built
Orange box
-PM range being built
Teal dashed line
-AM High or Low level
Orange dashed line
-PM High or Low level
ORBA▲
-Breakout above AM High
ORBA▼
-Breakdown below AM Low
ORBP▲
-Breakout above PM High
ORBP▼
-Breakdown below PM Low
Release Note
The ORB lines are displayed automatically to the last candle.The script run only on intraday timeframes.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
If you want to support further development - buy me a coffee!
paypal.com/donate/?business=AZNKQRW42YLSS&amount=5&no_recurring=1&item_name=Support+further+development!¤cy_code=EUR
paypal.com/donate/?business=AZNKQRW42YLSS&amount=5&no_recurring=1&item_name=Support+further+development!¤cy_code=EUR
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
If you want to support further development - buy me a coffee!
paypal.com/donate/?business=AZNKQRW42YLSS&amount=5&no_recurring=1&item_name=Support+further+development!¤cy_code=EUR
paypal.com/donate/?business=AZNKQRW42YLSS&amount=5&no_recurring=1&item_name=Support+further+development!¤cy_code=EUR
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน