mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-15 00:58:04 +00:00
xml doc rewrite
This commit is contained in:
@@ -1,11 +1,38 @@
|
||||
using System;
|
||||
namespace QuanTAlib;
|
||||
|
||||
/// <summary>
|
||||
/// MMA: Modified Moving Average
|
||||
/// A moving average that combines a simple moving average with a weighted component
|
||||
/// to provide a balanced smoothing effect. The weighting scheme emphasizes central
|
||||
/// values while maintaining overall data representation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The MMA calculation process:
|
||||
/// 1. Calculates the simple moving average component (T/period)
|
||||
/// 2. Calculates a weighted sum with symmetric weights around the center
|
||||
/// 3. Combines both components using the formula: SMA + 6*WeightedSum/((period+1)*period)
|
||||
///
|
||||
/// Key characteristics:
|
||||
/// - Combines simple and weighted moving averages
|
||||
/// - Symmetric weighting around the center
|
||||
/// - Better balance between smoothing and responsiveness
|
||||
/// - Reduces lag compared to simple moving average
|
||||
/// - Maintains stability through dual-component approach
|
||||
///
|
||||
/// Implementation:
|
||||
/// Based on modified moving average principles combining
|
||||
/// simple and weighted components for optimal smoothing
|
||||
/// </remarks>
|
||||
|
||||
public class Mma : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private double _lastMma;
|
||||
|
||||
/// <param name="period">The number of periods used in the MMA calculation. Must be at least 2.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Thrown when period is less than 2.</exception>
|
||||
public Mma(int period)
|
||||
{
|
||||
if (period < 2)
|
||||
@@ -19,6 +46,8 @@ public class Mma : AbstractBase
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <param name="source">The data source object that publishes updates.</param>
|
||||
/// <param name="period">The number of periods used in the MMA calculation.</param>
|
||||
public Mma(object source, int period) : this(period)
|
||||
{
|
||||
var pubEvent = source.GetType().GetEvent("Pub");
|
||||
@@ -61,6 +90,11 @@ public class Mma : AbstractBase
|
||||
return _lastMma;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the weighted sum component of the MMA.
|
||||
/// The weights are symmetric around the center, decreasing linearly from the center outward.
|
||||
/// </summary>
|
||||
/// <returns>The weighted sum of the data points.</returns>
|
||||
private double CalculateWeightedSum()
|
||||
{
|
||||
double sum = 0;
|
||||
|
||||
Reference in New Issue
Block a user