bogdanvlad
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: March 7th, 2022

Sum of daily values during that week on the weekly chart?

Hello!

I have the following script to plot the new highs of NASDAQ on the daily chart:

Code: Select all

//@version=5

indicator(title='New Highs NASDAQ')

highNsdaq = request.security('higq', timeframe.period, close)

plot(highNsdaq, title='New Highs NASDAQ', color=#B2B5BE)

But, let’s say that the new highs have the following daily values during a week:

Monday 100

Tuesday 101

Wednesday 102

Thursday 103

Friday 104

If I switch to the weekly chart, for each week I will get the highest value during that week, 104 for the example above.

Is there a way to get the sum of the new highs during that week on the weekly chart? For the example mentioned above, in the weekly chart, the value should be 510 and not 104.

Thank you!

Return to “Pine Script Q&A”