Syntax
public RAVI(DataSeries ds, int periodFast, int periodSlow, bool useSMA, bool useAbsolute, string description)
public static RAVI Series(DataSeries ds, int periodFast, int periodSlow, bool useSMA, bool useAbsolute)
Parameter Description
ds | DataSeries |
periodFast | Fast moving average period (default: 7) |
periodSlow | Slow moving average period (default: 65) |
useSMA | Use SMA (default) or EMA for the calculation |
useAbsolute | Take the absolute value of the result (default) as per the book by Tushar Chande or preserve trend direction |
Description
Chande's Range Action Verification Index (RAVI) indicator was developed by Tushar Chande. It's used to identify whether a market is trending. The RAVI indicator is calculated using two moving averages, fast and slow. The first one is a short moving average with a lookback period of 7 bars. The second one is a long moving average with a lookback period of 65 bars. The indicator returns a percentage value. Above a certain threshold, the market is considered trending.
References:
Example
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;
namespace WealthLab.Strategies
{
public class RAVI_ : WealthScript
{
protected override void Execute()
{
var ravi = RAVI.Series(Close, 7, 65, true, true);
ChartPane p = CreatePane(30, false, false); HideVolume();
PlotSeries(p, ravi, Color.Black, LineStyle.Solid, 3);
DrawHorzLine(p, 3, Color.Blue, LineStyle.Dashed, 1);
DrawHorzLine(p, -3, Color.Red, LineStyle.Dashed, 1);
for(int bar = 1; bar < Bars.Count; bar++)
{
SetSeriesBarColor(bar, ravi, (ravibar > ravibar-1) ? Color.Green : Color.Red);
}
}
}
}