OPEN-SOURCE SCRIPT
RTH Session Range Position (0-100) with EMA

A Pine Script indicator designed to help traders understand where the current price is located within the Regular Trading Hours (RTH) session range, from 0 (session low) to 100 (session high). It also plots a smoothed EMA of this position to provide insight into momentum or trend during the RTH session.
What the Indicator Does
Defines RTH (Regular Trading Hours):
Tracks the session's high and low during RTH:
Calculates position of the current price within the RTH range:
Calculates an EMA of that position (posEMA):
Plots and table:
Visual cues:
Alerts:
How to Use It Effectively
1. Session Strength & Momentum
2. Breakout or Reversal Detection
3. Range Context for Entries
If you're a mean-reversion trader, look for:
Price > 70 + turning down below EMA → possible short.
Price < 30 + turning up above EMA → possible long.
For breakout traders, you might wait for:
Crosses above 70 with EMA support.
Crosses below 30 with EMA resistance.
4. Confirmation Tool
Use this indicator alongside others to confirm:
What the Indicator Does
Defines RTH (Regular Trading Hours):
- Start: 9:30 AM
- End: 4:00 PM
- These are typical US equity market hours.
Tracks the session's high and low during RTH:
- sessionHigh and sessionLow update only during RTH.
Calculates position of the current price within the RTH range:
- Formula: ((close - sessionLow) / (sessionHigh - sessionLow)) * 100
- Result is a percentage:
- 0 = at session low
- 100 = at session high
- 50 = middle of session range
Calculates an EMA of that position (posEMA):
- Smooths out the raw position to help visualize momentum within the range.
Plots and table:
- Plots pos and posEMA on a separate chart pane.
- Adds horizontal lines at key levels (0, 30, 50, 70, 100).
- Table shows current values for Position, EMA, and Range.
Visual cues:
- bgcolor highlights when pos crosses over or under the EMA — potential momentum shifts.
Alerts:
- Cross above/below 50 (session midpoint).
- Cross above/below EMA.
How to Use It Effectively
1. Session Strength & Momentum
- Position above 70: Price is near session highs — strong upward momentum.
- Position below 30: Price is near session lows — strong downward momentum.
- Use the EMA of position to filter out noise and identify trends.
2. Breakout or Reversal Detection
- Cross above EMA: Momentum may be turning bullish.
- Cross below EMA: Momentum may be turning bearish.
- These crosses (especially near mid-levels like 50) can hint at session trend shifts.
3. Range Context for Entries
If you're a mean-reversion trader, look for:
Price > 70 + turning down below EMA → possible short.
Price < 30 + turning up above EMA → possible long.
For breakout traders, you might wait for:
Crosses above 70 with EMA support.
Crosses below 30 with EMA resistance.
4. Confirmation Tool
Use this indicator alongside others to confirm:
- Whether price action has strength within the day.
- Whether breakouts have real momentum or are extended already.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。