mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-30 02:27:43 +00:00
86fe32a682
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat> Co-authored-by: Warp <agent@warp.dev>
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System.Drawing;
|
|
using System.Runtime.CompilerServices;
|
|
using TradingPlatform.BusinessLayer;
|
|
|
|
namespace QuanTAlib;
|
|
|
|
[SkipLocalsInit]
|
|
public sealed class AdoscIndicator : Indicator, IWatchlistIndicator
|
|
{
|
|
[InputParameter("Fast Period", sortIndex: 1, 1, 1000, 1, 0)]
|
|
public int FastPeriod { get; set; } = 3;
|
|
|
|
[InputParameter("Slow Period", sortIndex: 2, 1, 1000, 1, 0)]
|
|
public int SlowPeriod { get; set; } = 10;
|
|
|
|
[InputParameter("Show cold values", sortIndex: 21)]
|
|
public bool ShowColdValues { get; set; } = true;
|
|
|
|
private Adosc _adosc = null!;
|
|
private readonly LineSeries _series;
|
|
|
|
public static int MinHistoryDepths => 0;
|
|
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
|
|
|
public override string ShortName => $"ADOSC {FastPeriod}:{SlowPeriod}";
|
|
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/volume/adosc/Adosc.Quantower.cs";
|
|
|
|
public AdoscIndicator()
|
|
{
|
|
OnBackGround = true;
|
|
SeparateWindow = true;
|
|
Name = "ADOSC - Accumulation/Distribution Oscillator";
|
|
Description = "Momentum indicator for the Accumulation/Distribution Line";
|
|
|
|
_series = new LineSeries(name: "ADOSC", color: Color.Orange, width: 2, style: LineStyle.Solid);
|
|
AddLineSeries(_series);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnInit()
|
|
{
|
|
_adosc = new Adosc(FastPeriod, SlowPeriod);
|
|
base.OnInit();
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnUpdate(UpdateArgs args)
|
|
{
|
|
TBar bar = this.GetInputBar(args);
|
|
TValue result = _adosc.Update(bar, args.IsNewBar());
|
|
|
|
_series.SetValue(result.Value, _adosc.IsHot, ShowColdValues);
|
|
}
|
|
}
|