OPEN-SOURCE SCRIPT

DAYOFWEEK performance

Atualizado
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

  • AVG OPEN-CLOSE

  • 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


Notes:
*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, 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 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)

https://www.tradingview.com/x/neblOvbq/

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 ( AAPL ) to 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%
https://www.tradingview.com/x/HWlTVvlP/

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


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


  • TABLE SETTINGS
    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



5 - LIMITATIONS
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:
https://www.tradingview.com/x/JYY1SGa0/


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.
Notas de Lançamento
█ 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
Candlestick AnalysisDAYdaylydayofweekday-tradingLinear RegressionVolume IndicatorweekWeekly Chartsweeklyforecastweeklymarketsanalysisweeklyoutlook

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal