mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-07 05:27:43 +00:00
15f4bb90f3
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
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using System.Drawing;
|
|
using System.Runtime.CompilerServices;
|
|
using TradingPlatform.BusinessLayer;
|
|
|
|
namespace QuanTAlib;
|
|
|
|
[SkipLocalsInit]
|
|
public sealed class BwMfiIndicator : Indicator, IWatchlistIndicator
|
|
{
|
|
[InputParameter("Show cold values", sortIndex: 21)]
|
|
public bool ShowColdValues { get; set; } = true;
|
|
|
|
private BwMfi _bwMfi = null!;
|
|
private readonly LineSeries _mfiLine;
|
|
private readonly LineSeries _zoneLine;
|
|
|
|
public static int MinHistoryDepths => 1;
|
|
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
|
|
|
public override string ShortName => "BW_MFI";
|
|
public override string SourceCodeLink => "https://github.com/mihakralj/QuanTAlib/blob/main/lib/oscillators/bw_mfi/BwMfi.Quantower.cs";
|
|
|
|
public BwMfiIndicator()
|
|
{
|
|
OnBackGround = true;
|
|
SeparateWindow = true;
|
|
Name = "BW_MFI - Bill Williams Market Facilitation Index";
|
|
Description = "Bill Williams' MFI with 4-zone classification. Zone 1 (Green): trend continuation. Zone 2 (Fade): fading. Zone 3 (Fake): unsupported. Zone 4 (Squat): breakout imminent.";
|
|
|
|
_mfiLine = new LineSeries("BW_MFI", Color.Cyan, 2, LineStyle.Histogramm);
|
|
_zoneLine = new LineSeries("Zone", Color.Gray, 1, LineStyle.Solid) { Visible = false };
|
|
AddLineSeries(_mfiLine);
|
|
AddLineSeries(_zoneLine);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnInit()
|
|
{
|
|
_bwMfi = new BwMfi();
|
|
base.OnInit();
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void OnUpdate(UpdateArgs args)
|
|
{
|
|
_ = _bwMfi.Update(this.GetInputBar(args), args.IsNewBar());
|
|
|
|
// Zone-based coloring
|
|
Color barColor = _bwMfi.Zone switch
|
|
{
|
|
1 => Color.Green, // Green zone
|
|
2 => Color.SaddleBrown, // Fade zone
|
|
3 => Color.Blue, // Fake zone
|
|
4 => Color.Fuchsia, // Squat zone
|
|
_ => Color.Gray // First bar
|
|
};
|
|
_mfiLine.SetValue(_bwMfi.Last.Value, _bwMfi.IsHot, ShowColdValues);
|
|
_mfiLine.SetMarker(0, barColor);
|
|
_zoneLine.SetValue(_bwMfi.Zone, _bwMfi.IsHot, ShowColdValues);
|
|
}
|
|
}
|