Strategy weekly results as numbers v1

This script is based on an idea of monthly statistics that have been found across tradingview community scripts. This is an improved version with weekly results with the ability to define the size of every group (number of weeks within one group).

Initial setup of the strategy
1. Set the period to calculate the results between.
2. Set the statistic precision and group size.
3. Enable "Recalculate" → "On every tick" under the strategy "Properties" section.

The logic under the hood
1. Get the period between which to calculate the strategy.
2. Calculate the first day of the first week within the period.
3. Calculate the latest day of the latest week within the period.
4. Calculate the results of the selected period.
5. Group the values by the defined number of cells.
6. Calculate the summary of every group.
7. Render the table.

Please, be careful. To use this tool you will need to enable the "Recalculate" → "On every tick" option but it means that your strategy will be executed on every tick instead of bar close. It can cause unexpected results in your strategy behaviour.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?