mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 05:48:06 +00:00
feat: Add Name property to EMA, SMA, and WMA classes for better identification
This commit is contained in:
@@ -38,6 +38,11 @@ public class Ema
|
|||||||
private State _p_state = State.New();
|
private State _p_state = State.New();
|
||||||
private double _lastValidValue;
|
private double _lastValidValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Display name for the indicator.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates EMA with specified period.
|
/// Creates EMA with specified period.
|
||||||
/// Alpha = 2 / (period + 1)
|
/// Alpha = 2 / (period + 1)
|
||||||
@@ -49,6 +54,7 @@ public class Ema
|
|||||||
throw new ArgumentException("Period must be greater than 0", nameof(period));
|
throw new ArgumentException("Period must be greater than 0", nameof(period));
|
||||||
|
|
||||||
_alpha = 2.0 / (period + 1);
|
_alpha = 2.0 / (period + 1);
|
||||||
|
Name = $"Ema({period})";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -61,6 +67,7 @@ public class Ema
|
|||||||
throw new ArgumentException("Alpha must be between 0 and 1", nameof(alpha));
|
throw new ArgumentException("Alpha must be between 0 and 1", nameof(alpha));
|
||||||
|
|
||||||
_alpha = alpha;
|
_alpha = alpha;
|
||||||
|
Name = $"Ema(α={alpha:F4})";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -47,11 +47,6 @@ public sealed class Sma
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of data points needed for the indicator to become "hot".
|
|
||||||
/// </summary>
|
|
||||||
public int WarmupPeriod { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates SMA with specified period.
|
/// Creates SMA with specified period.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -64,7 +59,6 @@ public sealed class Sma
|
|||||||
_period = period;
|
_period = period;
|
||||||
_buffer = new RingBuffer(period);
|
_buffer = new RingBuffer(period);
|
||||||
Name = $"Sma({period})";
|
Name = $"Sma({period})";
|
||||||
WarmupPeriod = period;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -55,11 +55,6 @@ public sealed class Wma
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of data points needed for the indicator to become "hot".
|
|
||||||
/// </summary>
|
|
||||||
public int WarmupPeriod { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates WMA with specified period.
|
/// Creates WMA with specified period.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -73,7 +68,6 @@ public sealed class Wma
|
|||||||
_divisor = period * (period + 1) * 0.5;
|
_divisor = period * (period + 1) * 0.5;
|
||||||
_buffer = new RingBuffer(period);
|
_buffer = new RingBuffer(period);
|
||||||
Name = $"Wma({period})";
|
Name = $"Wma({period})";
|
||||||
WarmupPeriod = period;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user