mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-18 18:48:05 +00:00
New indicators: - HWC (Holt-Winters Channel) — channels, 27 tests - VWMACD (Volume-Weighted MACD) — momentum, 38 tests - Squeeze Pro — oscillators, 69 tests - BW_MFI (Bill Williams MFI) — oscillators - DSTOCH (Double Stochastic) — oscillators - ATRSTOP (ATR Trailing Stop) — reversals - VSTOP (Volatility Stop) — reversals - Convexity (Beta Convexity) — statistics, 23 tests Integration: - Python bridge: Exports.cs, _bridge.py, wrapper modules - Documentation: _sidebar.md, _index.md pages, SPEC.md - All analyzer warnings fixed (MA0074, xUnit2013, S2699) Build: 0 warnings, 0 errors | Tests: 15,933 passed, 0 failed
67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
using System.Drawing;
|
|
using System.Runtime.CompilerServices;
|
|
using TradingPlatform.BusinessLayer;
|
|
|
|
namespace QuanTAlib;
|
|
|
|
[SkipLocalsInit]
|
|
public sealed class VwmacdIndicator : Indicator, IWatchlistIndicator
|
|
{
|
|
[InputParameter("Fast Period", sortIndex: 1, 1, 2000, 1, 0)]
|
|
public int FastPeriod { get; set; } = 12;
|
|
|
|
[InputParameter("Slow Period", sortIndex: 2, 1, 2000, 1, 0)]
|
|
public int SlowPeriod { get; set; } = 26;
|
|
|
|
[InputParameter("Signal Period", sortIndex: 3, 1, 2000, 1, 0)]
|
|
public int SignalPeriod { get; set; } = 9;
|
|
|
|
[InputParameter("Show cold values", sortIndex: 21)]
|
|
public bool ShowColdValues { get; set; } = true;
|
|
|
|
private Vwmacd _vwmacd = null!;
|
|
private readonly LineSeries _vwmacdSeries;
|
|
private readonly LineSeries _signalSeries;
|
|
private readonly LineSeries _histSeries;
|
|
|
|
public static int MinHistoryDepths => 0;
|
|
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
|
|
|
public override string ShortName => $"VWMACD({FastPeriod},{SlowPeriod},{SignalPeriod})";
|
|
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/momentum/vwmacd/Vwmacd.Quantower.cs";
|
|
|
|
public VwmacdIndicator()
|
|
{
|
|
OnBackGround = true;
|
|
SeparateWindow = true;
|
|
Name = "VWMACD - Volume-Weighted MACD";
|
|
Description = "MACD using Volume-Weighted Moving Averages instead of EMAs";
|
|
|
|
_vwmacdSeries = new LineSeries(name: "VWMACD", color: Color.Blue, width: 2, style: LineStyle.Solid);
|
|
_signalSeries = new LineSeries(name: "Signal", color: Color.Red, width: 2, style: LineStyle.Solid);
|
|
_histSeries = new LineSeries(name: "Histogram", color: Color.Green, width: 2, style: LineStyle.Solid);
|
|
|
|
AddLineSeries(_vwmacdSeries);
|
|
AddLineSeries(_signalSeries);
|
|
AddLineSeries(_histSeries);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnInit()
|
|
{
|
|
_vwmacd = new Vwmacd(FastPeriod, SlowPeriod, SignalPeriod);
|
|
base.OnInit();
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnUpdate(UpdateArgs args)
|
|
{
|
|
TBar bar = this.GetInputBar(args);
|
|
_vwmacd.Update(bar, args.IsNewBar());
|
|
|
|
_vwmacdSeries.SetValue(_vwmacd.Last.Value, _vwmacd.IsHot, ShowColdValues);
|
|
_signalSeries.SetValue(_vwmacd.Signal.Value, _vwmacd.IsHot, ShowColdValues);
|
|
_histSeries.SetValue(_vwmacd.Histogram.Value, _vwmacd.IsHot, ShowColdValues);
|
|
}
|
|
}
|