From 29f6f32934b35d658eed9b9a6182b1c041b630f9 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Wed, 18 Dec 2024 09:49:08 -0800 Subject: [PATCH] Add currency filter parameter to News indicator --- indicators/news/News.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/indicators/news/News.cs b/indicators/news/News.cs index 590a94e..0580f42 100644 --- a/indicators/news/News.cs +++ b/indicators/news/News.cs @@ -48,6 +48,7 @@ namespace NinjaTrader.NinjaScript.Indicators VerticalPadding = 5; YOffset = 0; CellBackgroundColor = Brushes.Transparent; + CurrencyFilter = "USD"; } else if (State == State.Configure) { @@ -103,6 +104,9 @@ namespace NinjaTrader.NinjaScript.Indicators string time = eventTime.ToString("hh:mmtt").ToLower(); + if (!string.IsNullOrEmpty(CurrencyFilter) && !currency.Equals(CurrencyFilter, StringComparison.OrdinalIgnoreCase)) + continue; // Skip events that do not match the filter. + newsEvents.Add(new NewsEvent { Time = time, Currency = currency, Title = title }); } } @@ -303,6 +307,10 @@ namespace NinjaTrader.NinjaScript.Indicators get { return Serialize.BrushToString(CellBackgroundColor); } set { CellBackgroundColor = Serialize.StringToBrush(value); } } + + [Display(Name = "Currency Filter", GroupName = "News", Order = 10)] + public string CurrencyFilter { get; set; } + #endregion } }