OPEN-SOURCE SCRIPT

Weekly High/Low Day Statistics

168
This indicator analyzes historical price data to determine which day of the week (Monday through Friday) most frequently hosts the weekly high and low prices. It provides overall counts, percentages, and the total number of weeks analyzed. Ideal for traders studying seasonal or day-of-week patterns in markets like futures (e.g., ES1!, NQ1!) or stocks (e.g., SPY).
Key Features:

Overall Statistics: Aggregates data across all available history, including the current partial week if applicable.
High/Low Tracking: Counts how many times each day was the weekly high or low, with percentages calculated over the total weeks.
Tie Handling: Uses the first occurrence in case of price ties (e.g., if multiple days hit the same high, the earliest day is credited).
Futures-Friendly: Utilizes time_tradingday for accurate day-of-week detection on continuous contracts like ES1!, accounting for session timings in UTC.
Table Display: Results are presented in a clean, semi-transparent table in the top-right corner, with columns for counts, percentages, and a total weeks summary.
Dynamic Updates: Processes all available historical bars on daily (1D) charts, supporting deep history (e.g., back to 2001 for ES1!). Note: On intraday timeframes, historical depth may be limited by TradingView's bar constraints.

How It Works:
The script iterates through daily bars, identifying the start of each new week via ta.change(time("W")). It tracks the highest and lowest prices within each week and assigns them to the corresponding trading day. At the end of each complete week, it tallies the results. The current incomplete week is included for real-time relevance.
Percentages are calculated as: (Count / Total Weeks) * 100, rounded to one decimal place.
Usage Tips:

Recommended Timeframe: Daily (1D) for maximum historical analysis. Works on intraday charts but with shallower data.
Symbols: Best for markets trading Monday-Friday, like indices, futures, or equities. Sunday/Saturday data is ignored as it's typically non-trading.
Customization: If ties should favor the last day instead, modify the comparison operators from >/< to >=/<= in the update logic.
Performance: Efficient for large datasets; no max_bars_back needed as it avoids deep historical references.

This tool can help uncover patterns, such as whether Fridays tend to be highs in bullish markets or Mondays lows during volatility. Use it alongside other indicators for comprehensive strategy building. Feedback welcome—feel free to suggest improvements!

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.