Log in

Sum

How the sum accumulates every value since the start, which sources it makes sense over, and how to use it in a QTSurfer strategy.

The sum is the total of every value since the start of the run.

Try it on a series below, over the price, which shows how it accumulates.

The series are samples, synthetic ones and real crypto ones. They show how the indicator behaves, not what it earns. The line is computed in your browser by the engine’s own indicator class, so it is the line a strategy reads.

What it computes

sum = previous sum + value        from the first update

It has no window and it adds every value from the first one its source is ready to give: the warm-up of an indicator is not added.

Reading it

  • Over the price it says little: it grows on every update and measures mostly how long the run is.
  • Over a flow it means something. The sum of a gain is the total of the rises since the start, and the sum of the volume is what was traded.
  • For the sum of the last N values, use an SMA with its third argument false, times N.

In a strategy

setup:
  gain("gains", "price")
  sum("gains")

sum("gains") registers sumgains, the total of the rises. The chart above runs sum("price"), which registers sumprice. In Java, .sum("gains") on the builder.

  • Gain and loss: values that are worth adding.
  • SMA: the mean of the last N values.
  • OBV: a sum of the volume with the sign of the move.
  • QTScript indicators and Java indicators: every indicator a strategy can call, with its forms and the names it registers.