mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-26 06:18:05 +00:00
volume indicators
This commit is contained in:
@@ -10,9 +10,10 @@ public class HemaTests
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new Hema(0));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new Hema(-1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new Hema(1));
|
||||
|
||||
var hema = new Hema(1);
|
||||
Assert.Equal("Hema(1)", hema.Name);
|
||||
var hema = new Hema(2);
|
||||
Assert.Equal("Hema(2)", hema.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -75,9 +75,9 @@ public sealed class Hema : AbstractBase
|
||||
|
||||
public Hema(int period)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(period);
|
||||
ArgumentOutOfRangeException.ThrowIfLessThan(period, 2);
|
||||
|
||||
double n = Math.Max((double)period, 2.0);
|
||||
double n = (double)period;
|
||||
_alphaSlow = AlphaFromHalfLife(n);
|
||||
_alphaFast = AlphaFromHalfLife(Math.Max(1.0, n * 0.5));
|
||||
_alphaSmooth = AlphaFromHalfLife(Math.Max(1.0, Math.Sqrt(n)));
|
||||
|
||||
Reference in New Issue
Block a user