This commit is contained in:
Miha Kralj
2024-10-08 13:59:33 -07:00
parent 46f5ffe9e9
commit 0bc41854aa
19 changed files with 48 additions and 218 deletions
+1 -17
View File
@@ -15,7 +15,6 @@ namespace QuanTAlib;
/// </remarks>
public class Rvi : AbstractBase
{
private readonly int Period;
private readonly Stddev _upStdDev, _downStdDev;
private readonly Sma _upSma, _downSma;
private double _previousClose;
@@ -27,17 +26,13 @@ public class Rvi : AbstractBase
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown when period is less than 2.
/// </exception>
<<<<<<< HEAD
public Rvi(int period) : base()
=======
public Rvi(int period)
>>>>>>> dev
{
if (period < 2)
{
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 2.");
}
Period = period;
int Period = period;
WarmupPeriod = period;
Name = $"RVI(period={period})";
_upStdDev = new Stddev(Period);
@@ -109,18 +104,7 @@ public class Rvi : AbstractBase
_downSma.Calc(_downStdDev.Calc(new TValue(Input.Time, downMove, Input.IsNew)));
double rvi;
<<<<<<< HEAD
if (_upSma.Value + _downSma.Value != 0)
{
rvi = 100 * _upSma.Value / (_upSma.Value + _downSma.Value);
}
else
{
rvi = 0;
}
=======
rvi = (_upSma.Value + _downSma.Value != 0) ? 100 * _upSma.Value / (_upSma.Value + _downSma.Value) : 0;
>>>>>>> dev
_previousClose = close;
IsHot = _index >= WarmupPeriod;