mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-31 19:07:42 +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>
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using System.Drawing;
|
|
using System.Runtime.CompilerServices;
|
|
using TradingPlatform.BusinessLayer;
|
|
|
|
namespace QuanTAlib;
|
|
|
|
[SkipLocalsInit]
|
|
public sealed class ApoIndicator : Indicator, IWatchlistIndicator
|
|
{
|
|
[InputParameter("Fast Period", sortIndex: 1, 1, 1000, 1, 0)]
|
|
public int FastPeriod { get; set; } = 12;
|
|
|
|
[InputParameter("Slow Period", sortIndex: 2, 1, 1000, 1, 0)]
|
|
public int SlowPeriod { get; set; } = 26;
|
|
|
|
[InputParameter("Show cold values", sortIndex: 21)]
|
|
public bool ShowColdValues { get; set; } = true;
|
|
|
|
private Apo _apo = null!;
|
|
private readonly LineSeries _series;
|
|
|
|
public static int MinHistoryDepths => 0;
|
|
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
|
|
|
public override string ShortName => $"APO {FastPeriod}:{SlowPeriod}";
|
|
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/momentum/apo/Apo.Quantower.cs";
|
|
|
|
public ApoIndicator()
|
|
{
|
|
OnBackGround = true;
|
|
SeparateWindow = true;
|
|
Name = "APO - Absolute Price Oscillator";
|
|
Description = "Momentum indicator showing the difference between two EMAs";
|
|
|
|
_series = new LineSeries(name: "APO", color: Color.Orange, width: 2, style: LineStyle.Solid);
|
|
AddLineSeries(_series);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnInit()
|
|
{
|
|
_apo = new Apo(FastPeriod, SlowPeriod);
|
|
base.OnInit();
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnUpdate(UpdateArgs args)
|
|
{
|
|
TValue result = _apo.Update(this.GetInputBar(args), args.IsNewBar());
|
|
|
|
_series.SetValue(result.Value, _apo.IsHot, ShowColdValues);
|
|
}
|
|
}
|