mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-28 01:37:43 +00:00
33d20f2a18
Complete thin Dx-composition wrapper indicators with full test coverage: - PlusDi/MinusDi: Directional Indicator wrappers (DiPlus/DiMinus from Dx) - PlusDm/MinusDm: Directional Movement wrappers (DmPlus/DmMinus from Dx) - Individual validation tests per indicator directory (TALib, Skender, bounds) - Combined unit tests (DiDm.Tests.cs) and validation tests (DiDm.Validation.Tests.cs) - Quantower wrappers + tests for all 4 indicators - PineScript v6 implementations with compensated RMA - Normalized .md documentation for all indicators and categories - 182 tests passing, 0 failures
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System.Drawing;
|
|
using System.Runtime.CompilerServices;
|
|
using TradingPlatform.BusinessLayer;
|
|
|
|
namespace QuanTAlib;
|
|
|
|
[SkipLocalsInit]
|
|
public sealed class PlusDiIndicator : Indicator, IWatchlistIndicator
|
|
{
|
|
[InputParameter("Period", sortIndex: 1, 1, 1000, 1, 0)]
|
|
public int Period { get; set; } = 14;
|
|
|
|
[InputParameter("Show cold values", sortIndex: 21)]
|
|
public bool ShowColdValues { get; set; } = true;
|
|
|
|
private PlusDi _plusDi = null!;
|
|
private readonly LineSeries _plusDiSeries;
|
|
|
|
public static int MinHistoryDepths => 0;
|
|
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
|
|
|
public override string ShortName => $"+DI {Period}";
|
|
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/dynamics/plusdi/PlusDi.Quantower.cs";
|
|
|
|
public PlusDiIndicator()
|
|
{
|
|
OnBackGround = true;
|
|
SeparateWindow = true;
|
|
Name = "+DI - Plus Directional Indicator";
|
|
Description = "Measures upward directional movement as a percentage of true range";
|
|
|
|
_plusDiSeries = new LineSeries(name: "+DI", color: Color.Green, width: 2, style: LineStyle.Solid);
|
|
|
|
AddLineSeries(_plusDiSeries);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnInit()
|
|
{
|
|
_plusDi = new PlusDi(Period);
|
|
base.OnInit();
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnUpdate(UpdateArgs args)
|
|
{
|
|
TValue result = _plusDi.Update(this.GetInputBar(args), args.IsNewBar());
|
|
|
|
_plusDiSeries.SetValue(result.Value, _plusDi.IsHot, ShowColdValues);
|
|
}
|
|
}
|