Seasonal Tendency (fadi)Seasonal tendency refers to the patterns in stock market performance that tend to repeat at certain times of the year. These patterns can be influenced by various factors such as economic cycles, investor behavior, and historical trends. For example, the stock market often performs better during certain months like November to April, a phenomenon known as the “best six months” strategy. Conversely, months like September are historically weaker.
These tendencies can help investors and traders make more informed decisions by anticipating potential market movements based on historical data. However, it’s important to remember that past performance doesn’t guarantee future results.
This indicator calculates the average daily move patterns over the specified number of years and then removes any outliers.
Settings
Number of years : The number of years to use in the calculation. The number needs to be large enough to create a pattern, but not so large that it may distort the price move.
Seasonality line color : The plotted line color.
Border : Show or hide the border and the color to use.
Grid : Show or hide the grid and the color to use.
Outlier Factor : The Outlier Factor is used to identify unusual price moves that are not typical and neutralize them to avoid skewing the predictions. It is the amount of deviation calculated using the total median price move.
Seasonaltendencies
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.
Seasonality Chart [LuxAlgo]The Seasonality Chart script displays seasonal variations of price changes that are best used on the daily timeframe. Users have the option to select the calculation lookback (in years) as well as show the cumulative sum of the seasonal indexes.
🔶 SETTINGS
Lookback (Years): Number of years to use for the calculation of the seasonality chart.
Cumulative Sum: Displays the cumulative sum of seasonal indexes.
Use Percent Change: Uses relative price changes (as a percentage) instead of absolute changes.
Linear Regression: Fits a line on the seasonality chart results using the method of least squares.
🔶 USAGE
Seasonality refers to the recurrent tendencies in a time series to increase or decrease at specific times of the year. The proposed tool can highlight the seasonal variation of price changes.
It is common for certain analysts to use a cumulative sum of these indexes to display the results, highlighting months with the most significant bullish/bearish progressions.
The above chart allows us to highlight which months prices tended to have their worst performances over the selected number of years.
🔹 Note
Daily price changes are required for the construction of the seasonal chart. Thus, charts using a low timeframe might lack data compared to higher ones. We recommend using the daily timeframe for the best user experience.
🔶 DETAILS
To construct our seasonal chart, we obtain the average price changes for specific days on a specific month over a user-set number of years from January to December. These individual averages form "seasonal indexes."
This is a common method in classical time series decomposition.
Example:
To obtain the seasonal index of price changes on January first we record every price change occuring on January first over the years of interest, we then average the result.
This operation is done for all days in each month to construct our seasonal chart.
Seasonal variations are often highlighted if the underlying time series is affected by seasonal factors. For market prices, it is difficult to assess if there are stable seasonal variations on all securities.
The consideration of seasonality by market practitioners has often been highlighted through strategies or observations. One of the most common is expressed by the adage "Sell in May and Go Away" for the US market. We can also mention:
January Effect
Santa Claus Rally
Mark Twain Effect
...etc.
These are commonly known as calendar effects and appear from the study of seasonal variations over certain years.
Multi-Asset Month/Month % change 10yr Averages10 Year Averages of Month-on-Month % change: Shows current asset, and 3x user input assets
-For comparing seasonal tendencies among different assets.
-Choose from a variety of monthly average measures as source: sma(close, length), sma(ohlc4, length); as well as sma's of vwap, vwma, volume, volatility. (sma = simple moving average).
-Averages based on month cf previous month: i.e. Feb % = Feb compared to Jan; Jan % = Jan compared to prev year's Dec. Average of the last 10yrs of these values is the printed value.
-Plot on current year (2023), or previous year (2022). If Plotting on current year, and a month of year has not yet occured, a 9yr average will be printed.
/// notes ///
-daily bars in month is a global setting; so choose assets which have similar trading days per month. i.e. Crypto: length = 30 (days per month); Stocks/FX/Indices: length = 21 (days per month).
-only plots on Daily timeframe.
10yr Avgs; Plotting with Year = 2022; using sma(close, 21) as source for average M/M change
Seasonal tendency: week-on-week % change and 10yr Averages-shows week-on-week % change, and 10yr averages of these % changes
-scan across the 10yr averages to get a good idea of the seasonality of an asset
-best used on commodities with strong seasonal tendencies (Gold, Wheat, Coffee, Lean hogs etc)
-works only on daily timeframe
-by default it will compare SMA(length) in the following way, BTC: Sunday cf previous Sunday | ES/Gold: Monday cf previous Monday
-for most assets, 5 daily bars in a week (SMA(5)) => that's the default. For BTC can change this to 7.
~~inputs:
-change input year to show any previous decade of asset's history; the table will display over that year on the chart
-choose expression for Average of % change week on week: SMA, ohlc4, vwma, vwap (default SMA)
-choose number of daily bars in a week (i.e. SMA length)
-change label sizes/colors
~~notes:
-When applied to current year: will print the 10yr average for previous weeks in the year; 9yr average for future weeks in the year
-drawings and SMA plot on the above chart are just to show visually how the week's average is calculated, and how this lines up with the label
-current week of year will highlight in large font orange by default
-the first 2 weeks of the year are omitted because of a bug i can't figure out, which throws out bad numbers.
-cannot print all the values for each of previous 10yrs; 'code too long' error. Could likely do this via using matrices but would require a rewrite
17th Dec 2022
@twingall
10yr, 20yr, 30yr Averages: Month/Month % Change; SeasonalityCalculates 10yr, 20yr and 30yr averages for month/month % change
~shows seasonal tendencies in assets (best in commodities). In above chart: August is a seasonally bullish month for Gold: All the averages agree. And January is the most seasonally bullish month.
~averages represent current month/previous month. i.e. Jan22 average % change represents whole of jan22 / whole of dec21
~designed for daily timeframe only: I found calling monthly data too buggy to work with, and I thought weekly basis may be less precise (though it would certainly reduce calculation time!)
~choose input year, and see the previous 10yrs of monthly % change readings, and previous 10yrs Average, 20yr Average, 30yr Average for the respective month. Labels table is always anchored to input year.
~user inputs: colors | label sizes | decimal places | source expression for averages | year | show/hide various sections
~multi-yr averges always print, i.e if only 10yrs history => 10yr Av = 20yr Av = 30yr Av. 'History Available' label helps here.
Based on my previously publised script: "Month/Month Percentage % Change, Historical; Seasonal Tendency"
Publishing this as seperate indicator because:
~significantly slower to load (around 13 seconds)
~non-premium users may not have the historical bars available to use 20yr or 30yr averages =>> prefer the lite/speedier version
~~tips~~
~after loading, touch the new right scale; then can drag the table as you like and seperate it from price chart
##Debugging/tweaking##
Comment-in the block at the end:
~test/verifify specific array elements elements.
~see the script calculation/load time
~~other ideas ~~
~could tweak the array.slice values in lines 313 - 355 to show the last 3 consecutive 10yr averages instead (i.e. change 0, 10 | 0,20 | 0, 30 to 0, 10 | 10, 20 | 20,30)
~add 40yr average by adding another block to each of the array functions, and tweaking the respective labels after line 313 (though this would likely add another 5 seconds to the load time)
~use alternative method for getting obtaining multi-year values from individual month elements. I used array.avg. You could try array.median, array.mode, array.variance, array.max, array.min (lines 313-355)
Month/Month Percentage % Change, Historical; Seasonal TendencyTable of monthly % changes in Average Price over the last 10 years (or the 10 yrs prior to input year).
Useful for gauging seasonal tendencies of an asset; backtesting monthly volatility and bullish/bearish tendency.
~~User Inputs~~
Choose measure of average: sma(close), sma(ohlc4), vwap(close), vwma(close).
Show last 10yrs, with 10yr average % change, or to just show single year.
Chose input year; with the indicator auto calculating the prior 10 years.
Choose color for labels and size for labels; choose +Ve value color and -Ve value color.
Set 'Daily bars in month': 21 for Forex/Commodities/Indices; 30 for Crypto.
Set precision: decimal places
~~notes~~
-designed for use on Daily timeframe (tradingview is buggy on monthly timeframe calculations, and less precise on weekly timeframe calculations).
-where Current month of year has not occurred yet, will print 9yr average.
-calculates the average change of displayed month compared to the previous month: i.e. Jan22 value represents whole of Jan22 compared to whole of Dec21.
-table displays on the chart over the input year; so for ES, with 2010 selected; shows values from 2001-2010, displaying across 2010-2011 on the chart.
-plots on seperate right hand side scale, so can be shrunk and dragged vertically.
-thanks to @gabx11 for the suggestion which inspired me to write this
Average Daily Pip Ranges by monthShows historical average daily pip ranges for specific months for FOREX pairs
useful for guaging typical seasonal volatility; or rough expected daily pip ranges for different months
works on both DXY and foreign currencies
option to plot 10yrs worth of data; with 10yr average of the average daily range for specific months
cast back to any previous 10yrs of your choosing
@twingall
SeasonsSeasons Indicator
What does this show?
This indicator shows the individual seasons to plot on a chart to see how an asset has performed historically during certain seasons.
Orange => Fall
White => Winter
Blue => Spring
Yellow => Summer
Seasonality: Month HighlightMany Assets, especially Commodities , have patterns of seasonality: Periods in the year when they have shown a greater tendency to rise or a greater tendency to fall.
The Seasonality of an asset is based on historical data (20yrs+): Specific asset seasonality charts can be found via an online search.
This is a simple tool that allows users to highlight and color code each of the 12 months of the year; depending on the seasonality of the specific asset.
The above chart shows Sugar Futures ; which are a seasonal 'sell' in February , and a seasonal 'buy' in May and August.
Seasonality should only be used to compliment a trading setup, NOT as a single reason in itself to buy or sell. Simply put: if you find a good setup, AND you have seasonality on your side; your odds of success are increased.