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
-12
View File
@@ -8,11 +8,7 @@ namespace QuanTAlib;
/// of the true range. The true range is the greatest of: current high - current low,
/// absolute value of current high - previous close, or absolute value of current low - previous close.
/// </remarks>
<<<<<<< HEAD
public class Atr : AbstractBarBase
=======
public class Atr : AbstractBase
>>>>>>> dev
{
private readonly Ema _ma;
private double _prevClose, _p_prevClose;
@@ -86,11 +82,7 @@ public class Atr : AbstractBase
/// </remarks>
protected override double Calculation()
{
<<<<<<< HEAD
ManageState(Input.IsNew);
=======
ManageState(BarInput.IsNew);
>>>>>>> dev
double trueRange = Math.Max(
Math.Max(
@@ -101,11 +93,7 @@ public class Atr : AbstractBase
);
if (_index < 2)
{
<<<<<<< HEAD
trueRange = Input.High - Input.Low;
=======
trueRange = BarInput.High - BarInput.Low;
>>>>>>> dev
}
TValue emaTrueRange = _ma.Calc(new TValue(Input.Time, trueRange, Input.IsNew));
-4
View File
@@ -25,11 +25,7 @@ public class Historical : AbstractBase
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown when period is less than 2.
/// </exception>
<<<<<<< HEAD
public Historical(int period, bool isAnnualized = true) : base()
=======
public Historical(int period, bool isAnnualized = true)
>>>>>>> dev
{
if (period < 2)
{
-4
View File
@@ -25,11 +25,7 @@ public class Realized : AbstractBase
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown when period is less than 2.
/// </exception>
<<<<<<< HEAD
public Realized(int period, bool isAnnualized = true) : base()
=======
public Realized(int period, bool isAnnualized = true)
>>>>>>> dev
{
if (period < 2)
{
+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;