OPEN-SOURCE SCRIPT
ที่อัปเดต: Gann Session Box - 6:00 PM Open, Auto-Expanding

Gann Session Box — Auto-Expanding High/Low/50%
Marks the range of the current trading session as a live box that grows in real time. The box anchors at the session open (6:00 PM ET by default, the CME/COMEX electronic open), then stretches upward or downward the moment a new session high or low prints. The 50% line always sits at the midpoint of the current range and re-centers automatically as the box expands.
How the session anchor works
Rather than testing the clock hour on each bar, the script shifts every bar's timestamp back by the configured session offset and watches the calendar date flip in that shifted frame. This is date-based rather than hour-based, so it stays correct across DST changes, holiday sessions, data gaps, and chart types that would otherwise skip the exact opening bar.
Second-chart support
On sub-minute charts TradingView only loads a few hours of history, so a 6 PM anchor frequently falls outside the loaded data and the session would never be detected. The session high, low and midpoint are therefore computed on a higher calculation timeframe (1 minute by default) via request.security, which pulls its own history independently of the chart's bar count. The result is a correct session range on a 1-second chart. Leave the calculation timeframe at 1 minute for second-based charts; raise it if you're on a slower chart and want fewer resource units.
Internal divisions
Optional subdivisions of the range:
Quarters — 25% / 50% / 75%
Gann eighths — 1/8 through 7/8, giving the standard eighth-based retracement grid within the session range
Inputs
Session start hour, minute and timezone
Calculation timeframe
Division mode, colors for box fill/border, high, low, midpoint and division lines
Toggles for flat H/L/mid rays, price labels, and retaining previous sessions' boxes
Notes
Set the symbol's session to Extended/Electronic hours. With RTH-only data the 6 PM bars don't exist and the box will anchor to the first available bar of the day instead. The default 6:00 PM with America/New_York is the ETH open for CME and COMEX products; if you switch the timezone dropdown, adjust the hour to match.
Marks the range of the current trading session as a live box that grows in real time. The box anchors at the session open (6:00 PM ET by default, the CME/COMEX electronic open), then stretches upward or downward the moment a new session high or low prints. The 50% line always sits at the midpoint of the current range and re-centers automatically as the box expands.
How the session anchor works
Rather than testing the clock hour on each bar, the script shifts every bar's timestamp back by the configured session offset and watches the calendar date flip in that shifted frame. This is date-based rather than hour-based, so it stays correct across DST changes, holiday sessions, data gaps, and chart types that would otherwise skip the exact opening bar.
Second-chart support
On sub-minute charts TradingView only loads a few hours of history, so a 6 PM anchor frequently falls outside the loaded data and the session would never be detected. The session high, low and midpoint are therefore computed on a higher calculation timeframe (1 minute by default) via request.security, which pulls its own history independently of the chart's bar count. The result is a correct session range on a 1-second chart. Leave the calculation timeframe at 1 minute for second-based charts; raise it if you're on a slower chart and want fewer resource units.
Internal divisions
Optional subdivisions of the range:
Quarters — 25% / 50% / 75%
Gann eighths — 1/8 through 7/8, giving the standard eighth-based retracement grid within the session range
Inputs
Session start hour, minute and timezone
Calculation timeframe
Division mode, colors for box fill/border, high, low, midpoint and division lines
Toggles for flat H/L/mid rays, price labels, and retaining previous sessions' boxes
Notes
Set the symbol's session to Extended/Electronic hours. With RTH-only data the 6 PM bars don't exist and the box will anchor to the first available bar of the day instead. The default 6:00 PM with America/New_York is the ETH open for CME and COMEX products; if you switch the timezone dropdown, adjust the hour to match.
Release Note
Gann Session Box — Auto-Expanding High/Low/50%Marks the range of the current trading session as a live box that grows in real time. The box anchors at the session open (6:00 PM ET by default, the CME/COMEX electronic open), then stretches upward or downward the moment a new session high or low prints. The 50% line always sits at the midpoint of the current range and re-centers automatically as the box expands.
How the session anchor works
Rather than testing the clock hour on each bar, the script shifts every bar's timestamp back by the configured session offset and watches the calendar date flip in that shifted frame. This is date-based rather than hour-based, so it stays correct across DST changes, holiday sessions, data gaps, and chart types that would otherwise skip the exact opening bar.
Second-chart support
On sub-minute charts TradingView only loads a few hours of history, so a 6 PM anchor frequently falls outside the loaded data and the session would never be detected. The session high, low and midpoint are therefore computed on a higher calculation timeframe (1 minute by default) via request.security, which pulls its own history independently of the chart's bar count. The result is a correct session range on a 1-second chart. Leave the calculation timeframe at 1 minute for second-based charts; raise it if you're on a slower chart and want fewer resource units.
Internal divisions
Optional subdivisions of the range:
Quarters — 25% / 50% / 75%
Gann eighths — 1/8 through 7/8, giving the standard eighth-based retracement grid within the session range
Inputs
Session start hour, minute and timezone
Calculation timeframe
Division mode, colors for box fill/border, high, low, midpoint and division lines
Toggles for flat H/L/mid rays, price labels, and retaining previous sessions' boxes
Notes
Set the symbol's session to Extended/Electronic hours. With RTH-only data the 6 PM bars don't exist and the box will anchor to the first available bar of the day instead. The default 6:00 PM with America/New_York is the ETH open for CME and COMEX products; if you switch the timezone dropdown, adjust the hour to match.
Release Note
Chart FixRelease Note
Chart Updateสคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน