twingall

10yr, 20yr, 30yr Averages: Month/Month % Change; Seasonality

twingall Telah dikemas kini   
Calculates 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)
Nota Keluaran:
show current month as different color and label size.
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 to use Tables
Nota Keluaran:
-cleaned up code comments
Nota Keluaran:
-added warning message if user is NOT on daily timeframe

You can buy me a coffee here...

PayPal.Me/twingall
BTC: 3JrhUwNRnKyqhaa1n1AXKeAubNeEFoch6S
ETH erc20: 0x4b0400B1c18503529ab69611e82a934DDe4Ab038
ETH bep20: 0x1F0f03F184079bb1085F8C9dF3a8191C9f5869B3
Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?