Seasonality Widget [LuxAlgo]The Seasonality Widget tool allows users to easily visualize seasonal trends from various data sources.
Users can select different levels of granularity as well as different statistics to express seasonal trends.
🔶 USAGE
Seasonality allows us to observe general trends occurring at regular intervals. These intervals can be user-selected from the granularity setting and determine how the data is grouped, these include:
Hour
Day Of Week
Day Of Month
Month
Day Of Year
The above seasonal chart shows the BTCUSD seasonal price change for every hour of the day, that is the average price change taken for every specific hour. This allows us to obtain an estimate of the expected price move at specific hours of the day.
Users can select when data should start being collected using the "From Date" setting, any data before the selected date will not be included in the calculation of the Seasonality Widget.
🔹 Data To Analyze
The Seasonality Widget can return the seasonality for the following data:
Price Change
Closing price minus the previous closing price.
Price Change (%)
Closing price minus the previous closing price, divided by the
previous closing price, then multiplied by 100.
Price Change (Sign)
Sign of the price change (-1 for negative change, 1 for positive change), normalized in a range (0, 100). Values above 50 suggest more positive changes on average.
Range
High price minus low price.
Price - SMA
Price minus its simple moving average. Users can select the SMA period.
Volume
Amount of contracts traded. Allow users to see which periods are generally the most /least liquid.
Volume - SMA
Volume minus its simple moving average. Users can select the SMA period.
🔹 Filter
In addition to the "From Date" threshold users can exclude data from specific periods of time, potentially removing outliers in the final results.
The period type can be specified in the "Filter Granularity" setting. The exact time to exclude can then be specified in the "Numerical Filter Input" setting, multiple values are supported and should be comma separated.
For example, if we want to exclude the entire 2008 period we can simply select "Year" as filter granularity, then input 2008 in the "Numerical Filter Input" setting.
Do note that "Sunday" uses the value 1 as a day of the week.
🔶 DETAILS
🔹 Supported Statistics
Users can apply different statistics to the grouped data to process. These include:
Mean
Median
Max
Min
Max-Min Average
Using the median allows for obtaining a measure more robust to outliers and potentially more representative of the actual central tendency of the data.
Max and Min do not express a general tendency but allow obtaining information on the highest/lowest value of the analyzed data for specific periods.
🔶 SETTINGS
Granularity: Periods used to group data.
From Data: Starting point where data starts being collected
🔹 Data
Analyze: Specific data to be processed by the seasonality widget.
SMA Length: Period of the simple moving average used for "Price - SMA" and "Volume - SMA" options in "Analyze".
Statistic: Statistic applied to the grouped data.
🔹 Filter
Filter Granularity: Period type to exclude in the processed data.
Numerical Filter Input: Determines which of the selected hour/day of week/day of month/month/year to exclude depending on the selected Filter Granularity. Only numerical inputs can be provided. Multiple values are supported and must be comma-separated.
Season
[SM] Bitcoin cycles bull market
An indicator to determine the seasonality / cyclicality of bitcoin for long trades.
Application
- For traders: Identification of zones with lower risk of entering long positions
- For swing traders and investors: customizable calendar of entries into long position
Indicator structure
1. Vertical zones (green and red) of time ranges. Only for historical bars. The range width is adjustable in the indicator settings.
2. Table (in the form of a calendar) for determining the time of entering a trade in the future. The table is not editable. It displays the result of the configured zones on the historical bars.
General settings
- choose the color of the Tradingview theme (light or dark)
Table settings
- Turn table display on / off
- Set the number of months to be displayed in the table
Settings of vertical zones (green and red)
Each cycle (1 month summer, 1 month autumn, ...) has four dates
- start date of the green zone (day and month)
- date of the end of the green zone
- start date of the red zone
- date of the end of the red zone
AlexD Market annual seasonalityThe indicator displays the percentage of bullish days with a given date over several years.
This allows you to determine the days of the year when the price usually goes up or down.
Indicator has a built-in "simple moving average" shifted back by half a period, due to which the delay of this smoothing is removed.
seasonThis script is meant to help verify the existence of a seasonal effect in asset returns, using a Z-test. There are three steps:
1. Think of a way to identify a season. The available methods are: by month, by week of the year, by day of the month, by day of the week, by hour of the day, and by minute of the hour.
2. Set the chart to the unit of your season. For example, if you want to check whether a crop commodity's harvest season has a seasonal implication, select "month". If you want to investigate the exchange's opening or close, select "hour".
3. Using the inputs, select the unit (e.g. "month", "dayofweek", "hour", etc.) and the range that identifies the season. The example natural gas chart has set "start" to 8 and "end" to 12 for September through December.
The test logic is as follows:
The "season" you select has a fixed length; for example, months eight through twelve has a length of four. This length is used to compute a sample mean, which is the mean return of all September-December periods in the chart. It is also used to calculate the mean/stdev of every other four-month period in the chart history. The latter is considered the "population." Using a Z-test, the script scores the difference between the sample returns and the population returns, and displays the results at two levels of significance (P = 0.05 and P = 0.01). The null hypothesis is "there is no difference between the seasonal periods and the population of ordinary periods". If the Z-score is sufficiently large or small, we can reject the null hypothesis and say that there is a seasonal effect at the given level of confidence. The output table will show green for a rejection of the null hypothesis (meaning there is a seasonal effect) or red of acceptance (there is no seasonal effect).
The seasonal periods that you have defined will be highlighted on the chart, so you can make sure they are correct. Additionally, the output table shows the mean, median, standard deviation, and top and bottom percentiles for both the seasonal and population samples.
Many news sites, twitter feeds, influences, etc. enjoy posting statistics about past returns, like "the stock market has gone up on this day 85 out of the past 100 years" and so on. Unfortunately, these posts don't tell you that many of these statistics are meaningless, as even totally random price fluctuations will cause many such interesting figures to occur. This script provides a limited means of testing some such seasonal effects so you can see if they are probably just random, or if they may have some meaning.
Note that Tradingview seems to use 1-based indexing for daily or higher timeframes, and 0-based indexing for intraday timeframes:
Months: 1-12
Weeks: 1-52
Days (of month): 1-31
Days (of week): 1-7
Hours (of day): 0-23
Minutes (of hour): 0-59
How To Set Trade Dates
Example how to backtest specific date(s) which can be useful for testing seasonality strategy ideas such as "Sell in May", etc.
If using Daily period with wild card dates it will not trade on 1st day of month. If market is closed will trade on next open day.
Works only with Daily or lower timeframes. When using on Daily timeframe set dates 1 day earlier to execute on desired dates.
Entering 0 in any of the date fields acts a wild card. Example -> Entry Year: 0 is "Every Year", Exit Month: 0 is "Every Month", etc.
NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!