Click or drag to resize

Root Mean Square

The root mean square (RootMeanSquare) (RMS) is defined as the square root of the mean square (the arithmetic mean of the squares of a set of numbers). The RMS is also known as the quadratic mean and is a particular case of the generalized mean with exponent 2. On the price charts it usually acts very similar to simple moving average indicator. But it can be very useful in case of charts with positive and negative values (e.g. z-score values).

Calculation

In the case of a set of N values Specification 029, the RMS is

Root Mean Square 002.

If Specification 027 is the arithmetic mean and Specification 028 is the standard deviation of a population then:

Root Mean Square 004

Chart Example

Root Mean Square 003

Implementation and Usage

To initialize root mean square indicator, use one of the following constructors:

RootMeanSquare – set default values: period = 14

RootMeanSquare(Int32) – set value for period

RootMeanSquare(TimeSpan) – sets time period

Use

RMS - property to get current value

Example
C#
 1// Create new instance
 2var indicator = new RootMeanSquare(28);
 3
 4// Number of stored values
 5indicator.HistoryCapacity = 2;
 6
 7// Add new data point
 8indicator.Add(CurrentPrice);
 9
10// Get indicator value
11double IndicatorValue = indicator.RMS;
12// Get previous value
13if (indicator.HistoryCount == 2)
14{
15    double IndicatorPrevValue = indicator[1];
16}