mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 03:58:04 +00:00
Refactor documentation links in numerics, oscillators, reversals, and statistics modules to use relative paths; update Bias class to handle division by zero more robustly; remove obsolete CUMMEAN Pine script; enhance trend indicators documentation; add Visual Studio Code workspace configuration.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
|
||||
namespace QuanTAlib;
|
||||
|
||||
[SkipLocalsInit]
|
||||
public sealed class EacpIndicator : Indicator, IWatchlistIndicator
|
||||
{
|
||||
[InputParameter("Min Period", sortIndex: 1, 3, 100, 1, 0)]
|
||||
public int MinPeriod { get; set; } = 8;
|
||||
|
||||
[InputParameter("Max Period", sortIndex: 2, 4, 500, 1, 0)]
|
||||
public int MaxPeriod { get; set; } = 48;
|
||||
|
||||
[InputParameter("Avg Length", sortIndex: 3, 0, 100, 1, 0)]
|
||||
public int AvgLength { get; set; } = 3;
|
||||
|
||||
[InputParameter("Enhance", sortIndex: 4)]
|
||||
public bool Enhance { get; set; } = true;
|
||||
|
||||
[IndicatorExtensions.DataSourceInput]
|
||||
public SourceType Source { get; set; } = SourceType.Close;
|
||||
|
||||
[InputParameter("Show cold values", sortIndex: 21)]
|
||||
public bool ShowColdValues { get; set; } = true;
|
||||
|
||||
private Eacp _eacp = null!;
|
||||
private readonly LineSeries _cycleSeries;
|
||||
private readonly LineSeries _powerSeries;
|
||||
private Func<IHistoryItem, double> _priceSelector = null!;
|
||||
|
||||
public static int MinHistoryDepths => 0;
|
||||
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
||||
|
||||
public override string ShortName => $"EACP ({MinPeriod},{MaxPeriod})";
|
||||
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/cycles/eacp/Eacp.Quantower.cs";
|
||||
|
||||
public EacpIndicator()
|
||||
{
|
||||
OnBackGround = true;
|
||||
SeparateWindow = true;
|
||||
Name = "EACP - Ehlers Autocorrelation Periodogram";
|
||||
Description = "Ehlers' Autocorrelation Periodogram estimates the dominant cycle period using autocorrelation and spectral analysis";
|
||||
|
||||
_cycleSeries = new LineSeries(name: "Cycle", color: IndicatorExtensions.Oscillators, width: 2, style: LineStyle.Solid);
|
||||
_powerSeries = new LineSeries(name: "Power", color: Color.Orange, width: 1, style: LineStyle.Dot);
|
||||
AddLineSeries(_cycleSeries);
|
||||
AddLineSeries(_powerSeries);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected override void OnInit()
|
||||
{
|
||||
_eacp = new Eacp(MinPeriod, MaxPeriod, AvgLength, Enhance);
|
||||
_priceSelector = Source.GetPriceSelector();
|
||||
base.OnInit();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
if (args.Reason != UpdateReason.NewBar && args.Reason != UpdateReason.HistoricalBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = this.HistoricalData[this.Count - 1, SeekOriginHistory.Begin];
|
||||
double value = _priceSelector(item);
|
||||
var time = this.HistoricalData.Time();
|
||||
|
||||
var input = new TValue(time, value);
|
||||
TValue result = _eacp.Update(input, args.IsNewBar());
|
||||
|
||||
_cycleSeries.SetValue(result.Value, _eacp.IsHot, ShowColdValues);
|
||||
_powerSeries.SetValue(_eacp.NormalizedPower * MaxPeriod, _eacp.IsHot, ShowColdValues);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user