mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-20 11:38:05 +00:00
event tests
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user