FinAnalysis User Guide

## Random Walk Index |

The Random
Walk Index (__Rwi__) is used to determine if a financial security is
trending or in a random trading range by comparing it to a straight line. The
more random the price movement, the more the __Rwi__ fluctuates. The
short-term (2 to 7 periods) __Rwi__ is an overbought/oversold indicator,
while the long-term (8 to 64 periods) RWI is a trend indicator. A financial
security is trending higher if the RWI of the highs is greater than 1, while a
downtrend is indicated if the __Rwi__ of the lows is greater than 1.

Market Signals

A buy signal
is generated when the long-term __Rwi__ of the highs is greater than 1 and
the short-term __Rwi__ of the lows rises above 1. A sell signal is
generated when the long-term __Rwi__ of the lows is greater than 1 and the
short-term __Rwi__ of the highs rises above 1.

Calculation

where __Atr__ is the average true
range over N periods preceding the current period. On each bar the calculation
is repeated varying N from 2 to the maximum look back. The highest value
becomes this bar’s __Rwi__ value.

There are two periods: fast (short) period and slow (long) period. RWLow and RWHigh are calculated for all using the formulas above. After that the maximum value for low and high are chosen. These will be LongRwiHigh and Long RwiLow.

The same process is implemented for to find ShortRwiHigh and ShortRwiLow.

Chart Example

Implementation and Usage

To initialize __Rwi__ use one of the
following constructors:

Rwi – sets default values: fastPeriod = 7, slowPeriod = 64. Fast period corresponds to short-term RWI, and slow period corresponds to long term RWI.

Rwi(Int32, Int32) – sets value for period

Use

properties to get current value

Example

C#

1// Create new instance 2Rwi rwi = new Rwi(10, 40); 3 4// Number of stored values 5rwi.HistoryCapacity = 2; 6 7// Add new data point 8rwi.Add(Bars.Current.Open, Bars.Current.High, Bars.Current.Low, Bars.Current.Close, Bars.Current.Volume); 9 10// Get indicator value 11double IndLongHighValue = rwi.LongRwiHigh; 12double IndLongLowValue = rwi.LongRwiLow; 13double IndShortHighValue = rwi.ShortRwiHigh; 14double IndShortLowValue = rwi.ShortRwiHigh; 15// Get previous values 16if (rwi.HistoryCount == 2) 17{ 18 double IndPrevLongHighValue = rwi[1].LongRwiHigh; 19 double IndPrevLongLowValue = rwi[1].LongRwiLow; 20 double IndPrevShortHighValue = rwi[1].ShortRwiHigh; 21 double IndPrevShortLowValue = rwi[1].ShortRwiHigh; 22}