Welcome to the BEST forum for traders

Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".

Sum of daily values on the weekly chart?

Sep 1, 2022 - 1:53 PM

Viewed 692 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/1328895 COPY
  • Hello!

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

    //@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!

    0
  • Yes, use that function (https://www.tradingview.com/pine-script-reference/v5/#fun_request{dot}security_lower_tf) to retrieve the daily values from a weekly chart and then use the https://www.tradingview.com/pine-script-reference/v5/#fun_array{dot}sum function to sum all those values into a float variable

    Does it make sense?

    0
CONTENTS