Files
QuanTAlib/lib/dynamics/vortex/Vortex.Quantower.cs
Miha Kralj 58f0812584 Add Vortex Indicator implementation and documentation
- Implemented Vortex Indicator in Vortex.cs, including calculation logic and event handling.
- Added detailed documentation for Vortex Indicator in Vortex.md, covering historical context, algorithm, outputs, and trading interpretation.
- Updated oscillators index to include TTM Wave indicator.
- Added TTM Wave documentation with algorithm and trading interpretation.
- Updated reversals index to include TTM Scalper Alert indicator.
- Added TTM Scalper Alert documentation with algorithm and trading strategy.
- Updated NDepend badges to reflect increased code metrics (classes, methods, lines of code, public types, comments, and complexity).
2026-02-06 07:43:40 -08:00

56 lines
1.9 KiB
C#

using System.Drawing;
using System.Runtime.CompilerServices;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
[SkipLocalsInit]
public sealed class VortexIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Period", sortIndex: 1, 2, 1000, 1, 0)]
public int Period { get; set; } = 14;
[InputParameter("Show cold values", sortIndex: 21)]
public bool ShowColdValues { get; set; } = true;
private Vortex _vortex = null!;
private readonly LineSeries _viPlusSeries;
private readonly LineSeries _viMinusSeries;
public static int MinHistoryDepths => 0;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public override string ShortName => $"Vortex {Period}";
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/dynamics/vortex/Vortex.Quantower.cs";
public VortexIndicator()
{
OnBackGround = true;
SeparateWindow = true;
Name = "Vortex";
Description = "Vortex Indicator identifies trend direction using VI+ and VI-";
_viPlusSeries = new LineSeries(name: "VI+", color: Color.Green, width: 2, style: LineStyle.Solid);
_viMinusSeries = new LineSeries(name: "VI-", color: Color.Red, width: 2, style: LineStyle.Solid);
AddLineSeries(_viPlusSeries);
AddLineSeries(_viMinusSeries);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override void OnInit()
{
_vortex = new Vortex(Period);
base.OnInit();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override void OnUpdate(UpdateArgs args)
{
_vortex.Update(this.GetInputBar(args), args.IsNewBar());
_viPlusSeries.SetValue(_vortex.ViPlus.Value, _vortex.IsHot, ShowColdValues);
_viMinusSeries.SetValue(_vortex.ViMinus.Value, _vortex.IsHot, ShowColdValues);
}
}