TradingView
twingall
19 Jul 2022 pukul 09.17

Month/Month Percentage % Change, Historical; Seasonal Tendency 

Wheat FuturesCBOT

Huraian

Table 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

Nota Keluaran

fixed label size error

Nota Keluaran

added formatting options: Current month color and label size; 10yr averages label size
~note: current active month value only be fully accurate as month completes: i.e. in mid July, July value will be [June average] compared to [mid-june to mid-july average]

Nota Keluaran

i.e. in mid July, July value will be: June average, compared to 'mid-june to mid-july' average

Nota Keluaran

Fixed occastional double-print glitch by changing from barstate.islast to barstate.islastconfirmedhistory

Nota Keluaran

-includes options for Volume (sma of volume) and Volatility (bollinger band width); comparing monthly % changes. Note: volume will not work on most FX pairs (no volume data there)

Nota Keluaran

-Updated Cover Chart to BTC. Bitcoin is where i find this indicator more useful (due to lack of seasonal data resources available for BTC, compared to traditional commodities)

Nota Keluaran

-added otions to toggle on/off last 10yrs; toggle on/off 10yr averages
Komen
Rise_of_Skywalker
Is it possible to put 10 year average monthly data for the securities like Apple & TSLA? Yearly data is not necessary.
twingall
@Rise_of_Skywalker, will dm you my test of this.. if can get workable (not to comute-time intense) solution, will update here too
Rise_of_Skywalker
@twingall, Thank you. I think we need to use Array function
twingall
@Rise_of_Skywalker, arrays won't help compute time i think, though they would be neater.. later this month will probably do a seperate indicator for 3x asset 10yr av only. it will be similar compute time to my other similar indicator: 10yr-20yr-30yr-Averages-Month-Month-Change-Seasonality
Rise_of_Skywalker
I tried to put the data in the table. I realised that row contains "barstate.islastconfirmedhistory" need to be removed. If I remove this row, what happen on the average 10 year calculation?
twingall
Rise_of_Skywalker
Awesome job!! This is a very good way of viewing a month to month percentage change. Is it possible to provide the stock prices in percentage changes? Possible to add additional row to calculate the change of percentage winning for the respective months for the pass ten years?
twingall
view stock price as % by toggling the scale, but that won't change indicator output. To compare % change of % change, tried redefining monthlyAverage(line 58) something like ta.roc(close, length) or ta.change(close,lengh), but spits out wierd numbers, and i don't think ta.roc or ta.change are good measures of month/month change.

the long& laborious way would be to add a tonne of new variables and plot them. i.e.:
febChgChg = pctChg(febChg, janChg)
marChgChg = pctChg(marChg, febChg)
etc etc
palitoj_endthen
nice...
Lebih