Previous Value

prev(Start Condition)


Some indicators start with a certain value and then build on that value. These indicators are mostly older indicators when computers were either not available or were in their infancy, so all calculations had to be done by hand. An initial value is calculated, and then this value is updated with every bar. Investigator allows you to create these indicators using a combination of the Start Condition and Previous Value functions. Make sure you are familiar with the Start Condition function before proceeding.


When you type in the Previous Value function, you need to select a designer indicator for the Start Condition for the indicator. (This indicator must have a Start Condition in it.) This is the initial value that will be used for the previous value function. With subsequent bars, this value is used for a calculation and is then updated.


An example is the Relative Strength Index (RSI):


To get the initial relative strength index value, you need to do a calculation called the Average Up. If a bar closes up from the previous bar, we add the difference between the current bar’s close and the previous bar’s close to a cumulative sum. We do this for the first 14 bars. This cumulative sum would be one of our start conditions. You then divide the sum of the up closes by 14 to get the Average Up.


You then use this as part of the calculation to compute the initial RSI value.


After the initial relative strength value, we calculate the Average Up by multiplying the previous bar’s Average Up value by 13, adding the amount of today’s bar up close, if any, and then dividing this value by 14. At this point, the previous value function for the Average Up is changed to this value.


Let’s look at a numerical example.


First, assume that the sum of the up closes for the first 15 bars is 35. This value would be obtained from a designer indicator that had a start condition whose function was to calculate this value. You then divide this value by 14 to get the previous value for bar 15:


Average Up = 2.5


Let’s then assume bar 16 closed up by a half a point. To get the next Average Up value, you take the previous bar’s Average Up value, which is 2.5, multiply it by 13, add .5 and then divide by 14:


((2.5 * 13) + .5) / 14 = 2.357


The previous value function would return 2.357 for bar 16, and then would update itself to this new value.


Let’s assume bar 17 closed down by 1 point. To get this bar’s Average Up value, you take the previous bar’s Average Up value, which is 2.357, multiply it by 13, add 0 and then divide by 14:


((2.357 * 13) + 0) / 14 = 2.188


The previous value function would return 2.188 for bar 17, and then would update itself to this new value.


This continues for the rest of the chart.


Most users will rarely have to use the previous value function, since, as stated before, the indicators that need it are mostly older indicators that were created when computers were either not available or were in their infancy. It is provided simply for backward compatibility.