DAYOFWEEK performance

1 -Objective
"What is the ''best'' day to trade .. Monday, Tuesday...."
This script aims to determine if there are different results depending on the day of the week.
The way it works is by dividing data by day of the week (Monday, Tuesday, Wednesday ... ) and perform calculations for each day of the week.

1 - Objective
2 - Features
3 - How to use (Examples)
4 - Inputs
5 - Limitations
6 - Notes
7 - Final Tooughs

2 - Features

    Calculate de Percentage change from day open to close
  • Green % (O-C)
    Percentage of days green (open to close)
  • Average Change
    Absolute day change (O-C)

  • AVG PrevD. Close-Close
    Percentage change from the previous day close to the day of the week close
    (Example: Monday ( C-C ) = Friday Close to Monday close
    Tuesday ( C-C ) = Monday C. to Tuesday C.
  • Green % (C1-C)
    Percentage of days green (open to close)

  • AVG Volume
    Day of the week Average Volume

*Mon(Nº) - Nº = Number days is currently calculated
Example: Monday (12) calculation based on the last 12 Mondays. Note: Discrepancies in numbers example Monday (12) - Friday (11) depend on the initial/end date or the market was closed (Holidays).

3 - How to use (Examples)

For the following example, NASDAQ:AAPL from 1 Jan 21 to 1 Jul 21 the results are following.
The highest probability of a Close being higher than the Open is Monday with 52.17 % and the Lowest Tuesday with 38.46 %. Meaning that there's a higher chance (for NASDAQ:AAPL ) of closing at a higher value on Monday while the highest chance of closing is lower is Tuesday. With an average gain on Tuesday of 0.21%
  • Long - The best day to buy (long) at open (on average) is Monday with a 52.2% probability of closing higher
  • Short- The best day to sell (short) at open (on average) is Tuesday with a 38.5% probability of closing higher (better chance of closing lower)

Since the values change from ticker to ticker, there is a substantial change in the percentages and days of the week. For example let's compare the previous example ( NASDAQ:AAPL ) to NYSE:GM (same settings)
For the same period, there is a substantial difference where there is a 62.5% probability Friday to close higher than the open, while Tuesday there is only a 28% probability.
With an average gain of 0.59% on Friday and an average loss of -0.34%

Also, the size of the table (number of days ) depends if the ticker is traded or not on that day as an example COINBASE:BTCUSD

4 - Inputs
    Initial Date - Date from which the script will start the calculation.
    End Date - Date to which the script will calculate.

    Text Color - Color of the displayed text
    Cell Color - Background color of table cells
    Header Color - Color of the column and row names
    Table Location - Change the position where the table is located.
    Table Size - Changes text size and by consequence the size of the table

The code determines average values based on the stored data, therefore, the range (Initial data) is limited to the first bar time.
As a consequence the lower the timeframe the shorter the initial date can be and fewer weeks can be calculated. To warn about this limitation there's a warning text that appears in case the initial date exceeds the bar limit.

Example with initial date 1 Jan 2021 and end date 18 Jul 2021 in 5m and 10 m timeframe:

6 - Notes and Disclosers
The script can be moved around to a new pane if need. -> Object Tree > Right Click Script > Move To > New pane

The code has not been tested in higher subscriptions tiers that allow for more bars and as a consequence more data, but as far I can tell, it should work without problems and should be in fact better at lower timeframes since it allows more weeks.

The values displayed represent previous data and at no point is guaranteed future values

7 - Final Tooughs
This script was quite fun to work on since it analysis behavioral patterns (since from an abstract point a Tuesday is no different than a Thursday), but after analyzing multiple tickers there are some days that tend to close higher than the open.

PS: If you find any mistake ex: code/misspelling please comment.
Catatan Pelepasan: █ Update script to the new pine script version 5
  • (New Features) - Now allows selecting times directly on the chart
  • (New Feature) - Warn users of valid setting instead of crashing
  • (Fix/Improvements) - Improved performance, removed unnecessary code
Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Rumah. Anda boleh menyukainya untuk menggunakannya pada carta.


Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?