OPEN-SOURCE SCRIPT

Performance Summary and Shading (Offset Version)

Modified "Recession and Crisis Shading" Indicator by haribotagada (Original Link: tradingview.com/v/ueWc5CGd/)

The updated indicator accepts a days offset (positive or negative) to calculate performance between the offset date and the input date.

Potential uses include identifying performance one week after company earnings or an FOMC meeting.

This feature simplifies input by enabling standardized offset dates, while still allowing flexibility to adjust ranges by overriding inputs as needed.

Summary of added features and indicator notes:
  • Inputs both positive and negative offset.
  • By default, the script calculates performance from the close of the input date to the close of the date at (input date + offset) for positive offsets, and from the close of (input date - offset) to the close of the input date for negative offsets. For example, with an input date of November 1, 2024, an offset of 7 calculates performance from the close on November 1 to the close on November 8, while an offset of -7 calculates from the close on October 25 to the close on November 1.
  • Allows user to perform the calculation using the open price on the input date instead of close price
  • The input format has been modified to allow overrides for the default duration, while retaining the original capabilities of the indicator.
  • The calculation shows both the average change and the average annualized change. For bar-wise calculations, annualization assumes 252 trading days per year. For date-wise calculations, it assumes 365 days for annualization.


Carries over all previous inputs to retain functionality of the previous script. Changes a few small settings:
  • Calculates start to end date performance by default instead of peak to trough performance.
  • Updates visuals of label text to make it easier to read and less transparent.
  • Changed stat box color scheme to make the text easier to read
  • Updated default input data to new format of input with offsets
  • Changed default duration statistic to number of days instead of number of bars with an option to select number of bars.


Potential Features to Add:
  • Import dataset from CSV files or by plugging into TradingView calendar


Example Input Datasets:
Recessions:
2020-02-01,COVID-19,59
2007-12-01,Subprime mortgages,547
2001-03-01,Dot-com,243
1990-07-01,Oil shock,243
1981-07-01,US unemployment,788
1980-01-01,Volker,182
1973-11-01,OPEC,485


Japan Revolving Door Elections
2006-09-26, Shinzo Abe
2007-09-26, Yasuo Fukuda
2008-09-24, Taro Aso
2009-09-16, Yukio Hatoyama
2010-07-08, Naoto Kan
2011-09-02, Yoshihiko Noda


Hope you find the modified indicator useful and let me know if you would like any features to be added!
multitimeframestatistics

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?


Full Disclaimer - linktr.ee/mintfinance
更多:

免责声明