Files
Miha Kralj 6f0a339c9b fix: resolve build and test errors
- Sar.Quantower.Tests.cs: add missing opening quote on string literal (line 48)
- Exports.cs: rename Correlation.Batch → Correl.Batch (CS0103)
- Ad.Validation.Tests.cs: fix Ooples OutputValues key "Ad" → "Adl"
2026-03-16 12:45:13 -07:00

58 lines
1.9 KiB
C#

using System.Drawing;
using System.Runtime.CompilerServices;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
[SkipLocalsInit]
public sealed class SarIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Start AF", sortIndex: 0, 0.001, 1.0, 0.001, 3)]
public double AfStart { get; set; } = 0.02;
[InputParameter("AF Increment", sortIndex: 1, 0.001, 1.0, 0.001, 3)]
public double AfIncrement { get; set; } = 0.02;
[InputParameter("Max AF", sortIndex: 2, 0.001, 1.0, 0.01, 2)]
public double AfMax { get; set; } = 0.20;
[InputParameter("Show cold values", sortIndex: 21)]
public bool ShowColdValues { get; set; } = true;
private Sar _indicator = null!;
private readonly LineSeries _sarSeries;
public static int MinHistoryDepths => 0;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public override string ShortName => $"SAR({AfStart:F2},{AfIncrement:F2},{AfMax:F2})";
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/reversals/sar/Sar.cs";
public SarIndicator()
{
OnBackGround = true;
SeparateWindow = false;
Name = "SAR - Parabolic Stop And Reverse";
Description = "Trend-following trailing stop indicator. SAR accelerates toward price as trend progresses, flipping on reversal.";
_sarSeries = new LineSeries(name: "SAR", color: Color.DodgerBlue, width: 2, style: LineStyle.Dot);
AddLineSeries(_sarSeries);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override void OnInit()
{
_indicator = new Sar(AfStart, AfIncrement, AfMax);
base.OnInit();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override void OnUpdate(UpdateArgs args)
{
_ = _indicator.Update(this.GetInputBar(args), args.IsNewBar());
_sarSeries.SetValue(_indicator.SarValue, _indicator.IsHot, ShowColdValues);
}
}