Weekday Close vs Open — Last N (per weekday)# Weekday Close vs Open - Last N Occurrences
This indicator distills every weekday's historical open-to-close behavior into a compact table so you can see how "typical" the current session is before the day even closes. It runs independently of your chart timeframe by pulling daily OHLCV data under the hood, tracking the last **N** completed occurrences for each weekday, and refreshing only when a daily bar closes. On daily charts you can also shade every past bar that matches today's weekday (excluding the in-progress session) to reinforce the pattern visually while the table remains non-repainting.
## What It Shows
- **Win/Loss/Tie counts** - how many of the last `N` occurrences closed above the open (wins), below (losses), or inside the tie threshold you define as "flat".
- **Win % heatmap** - the win column is color-coded (deep green > deep red) so you immediately recognize strong or weak weekdays.
- **Advanced metrics (optional)** - average daily volume plus the average percentage excursion above/below the open (`AvgUp%`, `AvgDn%`) for that weekday.
- **Totals row** - aggregates every weekday into one row to estimate overall hit rate and average stats across the entire data set.
- **Weekday shading (optional)** - on daily charts you can tint every bar that matches today's weekday (all Mondays, all Fridays, etc.) for instant pattern recognition.
## How It Works
1. The script requests daily OHLCV data (non-repainting) regardless of the chart timeframe.
2. When a new daily bar confirms, it packs that day's data into one of seven arrays (one per weekday). Each day contributes five floats (O/H/L/C/V) so trimming and statistics stay in lockstep.
3. A helper function (`f_dayMetrics`) scans daily history to compute average volume, average excursion above/below the open, and win/loss/tie counts for the requested weekday.
4. The table populates on the last bar of the chart session, respecting your advanced/totals toggles and keeping text at `size.normal`.
## Reading the Table
- **Win/Loss/Tie columns**: raw counts taken from your chosen `N`.
- **Win %***: excludes ties from the denominator so it reflects only decisive closes.
- **AvgUp% / AvgDn%**: typical intraday extension (high vs open, open vs low) in percent.
- **Avg Vol**: arithmetic mean of daily volume for that weekday.
- **TOTAL row**: provides a global win rate plus volume/up/down averages weighted by how many samples each weekday contributed.
## Practical Uses
- Spot weekdays that historically trend higher or lower before entering a trade.
- Compare current price action against the typical intraday range (`AvgUp%` vs today's move).
- Filter mean-reversion vs breakout setups based on the most reliable weekday patterns.
- Quickly gauge whether today is behaving "in character" by referencing the highlighted row or the optional whole-chart weekday shading.
> **Tip:** Use smaller `N` values (e.g., 10-20) for adaptive, recent behavior and larger values (50+) to capture longer-term seasonality. Tighten the tie threshold if you want almost every candle to register as win/loss, or widen it to focus only on meaningful moves.
Weekday
Time of Day and Day of Week Buying and Selling StrategyThis strategy allows you to back test longing or shorting or do nothing during time increments of 30 minutes for various days of the week. For example if you want to see if every Saturday if Bitcoin dropped in value from 1600-7000 UTC, this script will allow you to test that.
Make sure you are in the 30 minute time frame while viewing the performance and trade history.
Day of Week Custom Buy/Sell StrategyThis strategy was made for bitcoin and allows you to back test longing or shorting for various days of the week. The price may tend to go in one direction or another for each week day, and this strategy allows you to test days across a range of dates to capitalize on this.
Make sure you are on the daily time frame while viewing the performance and trade history to ensure the script works as intended and you have the most historical data as possible from Trading View.



