mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 13:08:04 +00:00
CTI - Ehler's Correlation Trend - calc and chart
This commit is contained in:
@@ -87,7 +87,8 @@ public class EventingTests
|
||||
("Rse", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
|
||||
("Smape", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
|
||||
("Rsquared", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod }),
|
||||
("Huber", new object[] { DefaultPeriod, 1.0 }, new object[] { new TSeries(), DefaultPeriod, 1.0 })
|
||||
("Huber", new object[] { DefaultPeriod, 1.0 }, new object[] { new TSeries(), DefaultPeriod, 1.0 }),
|
||||
("Cti", new object[] { DefaultPeriod }, new object[] { new TSeries(), DefaultPeriod })
|
||||
};
|
||||
|
||||
private static readonly (string Name, object[] DirectParams, object[] EventParams)[] BarIndicators = new[]
|
||||
@@ -121,10 +122,10 @@ public class EventingTests
|
||||
return new TBar(
|
||||
DateTime.Now,
|
||||
baseValue,
|
||||
baseValue + Math.Abs(GetRandomDouble(rng) * 10),
|
||||
baseValue - Math.Abs(GetRandomDouble(rng) * 10),
|
||||
baseValue + Math.abs(GetRandomDouble(rng) * 10),
|
||||
baseValue - Math.abs(GetRandomDouble(rng) * 10),
|
||||
baseValue + (GetRandomDouble(rng) * 5),
|
||||
Math.Abs(GetRandomDouble(rng) * 1000),
|
||||
Math.abs(GetRandomDouble(rng) * 1000),
|
||||
true
|
||||
);
|
||||
}
|
||||
@@ -150,7 +151,7 @@ public class EventingTests
|
||||
}
|
||||
|
||||
bool areEqual = (double.IsNaN(directIndicator.Value) && double.IsNaN(eventIndicator.Value)) ||
|
||||
Math.Abs(directIndicator.Value - eventIndicator.Value) < Tolerance;
|
||||
Math.abs(directIndicator.Value - eventIndicator.Value) < Tolerance;
|
||||
|
||||
Assert.True(areEqual, $"Value indicator {indicatorName} failed: Expected {directIndicator.Value}, Actual {eventIndicator.Value}");
|
||||
}
|
||||
@@ -176,7 +177,7 @@ public class EventingTests
|
||||
}
|
||||
|
||||
bool areEqual = (double.IsNaN(directIndicator.Value) && double.IsNaN(eventIndicator.Value)) ||
|
||||
Math.Abs(directIndicator.Value - eventIndicator.Value) < Tolerance;
|
||||
Math.abs(directIndicator.Value - eventIndicator.Value) < Tolerance;
|
||||
|
||||
Assert.True(areEqual, $"Bar indicator {indicatorName} failed: Expected {directIndicator.Value}, Actual {eventIndicator.Value}");
|
||||
}
|
||||
|
||||
@@ -160,5 +160,9 @@ namespace QuanTAlib
|
||||
[Fact] public void Trix() => TestIndicator<momentum::QuanTAlib.TrixIndicator>("Series");
|
||||
[Fact] public void Vel() => TestIndicator<momentum::QuanTAlib.VelIndicator>("Series");
|
||||
[Fact] public void Vortex() => TestIndicatorMultipleFields<momentum::QuanTAlib.VortexIndicator>(new[] { "PlusLine", "MinusLine" });
|
||||
|
||||
// Oscillators Indicators
|
||||
[Fact] public void Cti() => TestIndicator<oscillator::QuanTAlib.CtiIndicator>("Series");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,4 +172,11 @@ public class OscillatorsUpdateTests : UpdateTestBase
|
||||
|
||||
Assert.Equal(initialValue, finalValue, precision);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Cti_Update()
|
||||
{
|
||||
var indicator = new Cti(period: 20);
|
||||
TestTValueUpdate(indicator, indicator.Calc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user