MA_PT

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

  • 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, 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
  • 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:


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.
開源腳本

秉持真正的TradingView精神,該腳本的作者將其開源發佈,因此交易者可以理解和驗證它。為作者加油!您可以免費使用它,但是在發佈中重複使用此程式碼受網站規則的約束。您可以把它加入到常用以在圖表上使用它。

想在圖表上使用此腳本?

評論

were you able to get around market holidays affecting data?
回覆
MA_PT Uni_ve12se
@Uni_ve12se, Not sure if I´m understanding what you mean by "affecting data", currently the script calculates based on available data therefore holidays don't "affect per say" the data. The other way you may want to interpret data is to ignore entire weeks when there's a holiday present.
I opted to include weeks where there were holidays to better reflect the data over time.
Hope my answer helps, Best regards.
回覆