Running Total

rt(Num Bars, Min Bars, Of What, Num Bars Ago)


Num Bars = -1 for All Bars; Min Bars = 0 (false), 1 (true)


The running total function always starts with zero. It will then add to the running total the values Of What parameter returns. If you have the Use Designer Dialogs option checked, a dialog box will appear where you must enter the number of bars for the running total. You can either enter the number of desired bars, or you can click the All Bars option. (If you are not using the Designer Dialogs, you would enter the number of bars, or -1 for all bars.)


If the all bars option is used, it will keep a running total for every value it receives. For example, if you wanted to keep a count of the number of bars in a file, you would drag in the running total icon (clicking the all bars check box) and then enter the number 1 as the Of What parameter. This would add one for every bar in the file.


If you don't use the all bars option, the running total function will just keep the total for the number of bars you specify. For example, if you wanted an indicator that was the sum of the last three bar's volume, you would enter three in the number of periods edit box, and then enter “v” or “vol” in the Of What parameter.


You then must enter the number of bars ago value. This will almost always be zero.


Finally, you can click the Must Have Minimum Bars checkbox (or enter 0 for false or 1 for true in the Min Bars parameter if you’re not using Designer Dialogs.). If the indicator you are designing must have at least a certain number of bars for its calculation, check this box. In our first example where we wanted to keep a count of the number of bars in a file, we would not check this box, since we don’t need a minimum number of bars. (Actually, if you check the All Bars checkbox, the Must Have Minimum Bars checkbox will be ignored). However, for our sum of the last three bar's volumes, we would check the Must Have Minimum Bars checkbox, since we need at least three bars for the indicator. If this box was not checked, the indicator’s value for the first bar would be the volume for that bar. The indicator’s value for the second bar would be the sum of the first and second bar’s volume. Finally, we would get an accurate value on the third bar.


Warning: the running total function will do exactly what it is told to do. This can become a problem with indicators like Directional Movement. The creator of DMI uses a value of 14 to create his indicator. One of the requirements for DMI is to get the first 14 bar’s average true ranges, so we would require a running total of the first 14 bars true ranges with the Must Have Minimum Bars checkbox checked, right? Wrong. To calculate the true range of a bar, we need at least 2 bars, the current bar and the previous bar. To calculate the average true ranges on bar fourteen, you need a running total of 13 bars true ranges with the Must Have Minimum Bars checkbox checked, since you cannot calculate the true range of the first bar in the file.