A Consecutive Sum Indicator

Note – the following indicator is provided for our most advanced users only, and we are not suggesting that it has many uses beyond education. It is complicated and beyond the scope of our technical support services to assist you in either understanding or extending the use of this indicator.

The consecutive sum indicator takes two parameters, a time series and a condition. The consecutive sum computes the sum of the time series for all previous consecutive bars where the condition is true. It would be equivalent to implementing a loop in other indicator languages which goes backwards in time summing up previous values as long as the condition is true.

Note that if the series you sum is add2(1,0) then you are essentially counting the consecutive bars where the condition is true.

As an example, if you wanted to compute the sum of the volume over consecutive bars where the price was increasing, you would use ConsecutiveSum ( Volume, A>B(Momentum(Close,1), 0 ).

For those interested in creating similar indicators, the ConsecutiveSum indicator is the difference between the current cumulative sum and the value of the cumulative sum on the last bar the condition was not true. It was created using the following indicator with the X’s mapped to one parameter and the numeric parameters hidden:

Sub ( CumulativeSum (X,0), SelectiveMovAvg( CumulativeSum(X,0), Not

Click here to download the .tpl file for the consecutive sum indicator. Store it in the Template folder of your NeuroShell Trader folder.

Was this article helpful?

Related Articles