Cumulative sum
Fri Sep 02 2022 11:23:42 GMT+0000 (Coordinated Universal Time)
Saved by
@nolimits
##sum
##loop
// Built in Function, sums last 100 bars
sum = math.sum(volume, 100)
// For better understanding keep in mind that pine script executes for each bar, starting at bar 0 at the most left (old) bar.
// Initialize variable (as a float) and then calculate
// Using var we init once in a time the variable
var sum = 0.0
sum += volume
// Other option without using var
sum = 0.0
sum = nz(sum[1]) + volume
// In this example the variable sum is reset to 0 every bar before accessing the last bar value and adding the volume
content_copyCOPY
Comments