event tests

This commit is contained in:
Miha Kralj
2024-10-08 09:25:01 -07:00
parent b7b5a4a1bf
commit af234594cc
15 changed files with 391 additions and 200 deletions
+7 -7
View File
@@ -8,7 +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>
public class Atr : AbstractBarBase {
public class Atr : AbstractBase {
private readonly Ema _ma;
private double _prevClose, _p_prevClose;
@@ -72,22 +72,22 @@ public class Atr : AbstractBarBase {
/// as the true range.
/// </remarks>
protected override double Calculation() {
ManageState(Input.IsNew);
ManageState(BarInput.IsNew);
double trueRange = Math.Max(
Math.Max(
Input.High - Input.Low,
Math.Abs(Input.High - _prevClose)
BarInput.High - BarInput.Low,
Math.Abs(BarInput.High - _prevClose)
),
Math.Abs(Input.Low - _prevClose)
Math.Abs(BarInput.Low - _prevClose)
);
if (_index < 2) {
trueRange = Input.High - Input.Low;
trueRange = BarInput.High - BarInput.Low;
}
TValue emaTrueRange = _ma.Calc(new TValue(Input.Time, trueRange, Input.IsNew));
IsHot = _ma.IsHot;
_prevClose = Input.Close;
_prevClose = BarInput.Close;
return emaTrueRange.Value;
}