Files
Miha Kralj 75c6a9f135 Enhance validation tests for various indicators with external library comparisons
- Added detailed comments explaining the validation limitations for MMA and ZLEMA due to differences in algorithm implementations.
- Implemented validation tests for True Range against TALib and Tulip, ensuring directional agreement.
- Updated Ulcer Index validation to clarify differences in algorithmic approaches between QuanTAlib and Skender.
- Enhanced Ease of Movement tests to verify directional agreement with Tulip's EMV, noting differences in volume scaling.
- Expanded Klinger Volume Oscillator tests to validate against Skender and Tulip, focusing on directional agreement across multiple period configurations.
- Improved Negative Volume Index tests to compare percentage changes with Tulip, addressing differences in starting values.
- Updated Positive Volume Index tests to validate against Tulip, emphasizing percentage change comparisons.
- Enhanced Williams Accumulation/Distribution tests to verify directional agreement with Tulip, highlighting formula differences.
2026-02-11 14:46:56 -08:00

70 lines
2.5 KiB
C#

using System.Drawing;
using System.Runtime.CompilerServices;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
/// <summary>
/// PMO (Price Momentum Oscillator) Quantower indicator.
/// Double-smoothed rate of change measuring momentum with reduced noise.
/// Formula: ROC% → EMA → EMA
/// </summary>
[SkipLocalsInit]
public sealed class PmoIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("ROC Period", sortIndex: 1, 1, 2000, 1, 0)]
public int RocPeriod { get; set; } = 35;
[InputParameter("Smooth1 Period", sortIndex: 2, 1, 2000, 1, 0)]
public int Smooth1Period { get; set; } = 20;
[InputParameter("Smooth2 Period", sortIndex: 3, 1, 2000, 1, 0)]
public int Smooth2Period { get; set; } = 10;
[IndicatorExtensions.DataSourceInput]
public SourceType Source { get; set; } = SourceType.Close;
[InputParameter("Show cold values", sortIndex: 21)]
public bool ShowColdValues { get; set; } = true;
private Pmo _pmo = null!;
private string _sourceName = null!;
private Func<IHistoryItem, double> _priceSelector = null!;
public static int MinHistoryDepths => 0;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public override string ShortName => $"PMO({RocPeriod},{Smooth1Period},{Smooth2Period}):{_sourceName}";
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/momentum/pmo/Pmo.Quantower.cs";
public PmoIndicator()
{
OnBackGround = true;
SeparateWindow = true;
_sourceName = Source.ToString();
Name = "PMO - Price Momentum Oscillator";
Description = "Double-smoothed rate of change for momentum analysis";
AddLineSeries(new LineSeries(name: "PMO", color: Color.Blue, width: 2, style: LineStyle.Solid));
AddLineSeries(new LineSeries(name: "Zero", color: Color.Gray, width: 1, style: LineStyle.Dot));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override void OnInit()
{
_pmo = new Pmo(RocPeriod, Smooth1Period, Smooth2Period);
_sourceName = Source.ToString();
_priceSelector = Source.GetPriceSelector();
base.OnInit();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override void OnUpdate(UpdateArgs args)
{
TValue result = _pmo.Update(new TValue(this.GetInputBar(args).Time, _priceSelector(HistoricalData[Count - 1, SeekOriginHistory.Begin])), args.IsNewBar());
LinesSeries[0].SetValue(result.Value, _pmo.IsHot, ShowColdValues);
LinesSeries[1].SetValue(0);
}
}