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.
Seasonaltrade
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)