From 9df47c8adecafc1fababc434f7c351cb6eaf351a Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 26 Sep 2024 06:31:37 -0700 Subject: [PATCH] Remove NinjaScriptProperty attributes from plot properties so that strategies based on the %B indicator are not required to pass them into the constructor --- indicators/%b/PercentB.cs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/indicators/%b/PercentB.cs b/indicators/%b/PercentB.cs index 90b02a2..c719384 100644 --- a/indicators/%b/PercentB.cs +++ b/indicators/%b/PercentB.cs @@ -76,21 +76,17 @@ namespace NinjaTrader.NinjaScript.Indicators [Display(Name = "Standard Deviations", GroupName = "%B", Order = 2)] public double StandardDeviations { get; set; } - [NinjaScriptProperty] [Range(double.MinValue, double.MaxValue)] [Display(Name = "Upper Level", GroupName = "Plots", Order = 2)] public double UpperLevel { get; set; } - [NinjaScriptProperty] [Display(Name = "Upper Level Stroke", GroupName = "Plots", Order = 3)] public Stroke UpperLevelStroke { get; set; } - [NinjaScriptProperty] [Range(double.MinValue, double.MaxValue)] [Display(Name = "Lower Level", GroupName = "Plots", Order = 4)] public double LowerLevel { get; set; } - [NinjaScriptProperty] [Display(Name = "Lower Level Stroke", GroupName = "Plots", Order = 5)] public Stroke LowerLevelStroke { get; set; } @@ -105,18 +101,18 @@ namespace NinjaTrader.NinjaScript.Indicators public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private PercentB[] cachePercentB; - public PercentB PercentB(int period, double standardDeviations, double upperLevel, Stroke upperLevelStroke, double lowerLevel, Stroke lowerLevelStroke) + public PercentB PercentB(int period, double standardDeviations) { - return PercentB(Input, period, standardDeviations, upperLevel, upperLevelStroke, lowerLevel, lowerLevelStroke); + return PercentB(Input, period, standardDeviations); } - public PercentB PercentB(ISeries input, int period, double standardDeviations, double upperLevel, Stroke upperLevelStroke, double lowerLevel, Stroke lowerLevelStroke) + public PercentB PercentB(ISeries input, int period, double standardDeviations) { if (cachePercentB != null) for (int idx = 0; idx < cachePercentB.Length; idx++) - if (cachePercentB[idx] != null && cachePercentB[idx].Period == period && cachePercentB[idx].StandardDeviations == standardDeviations && cachePercentB[idx].UpperLevel == upperLevel && cachePercentB[idx].UpperLevelStroke == upperLevelStroke && cachePercentB[idx].LowerLevel == lowerLevel && cachePercentB[idx].LowerLevelStroke == lowerLevelStroke && cachePercentB[idx].EqualsInput(input)) + if (cachePercentB[idx] != null && cachePercentB[idx].Period == period && cachePercentB[idx].StandardDeviations == standardDeviations && cachePercentB[idx].EqualsInput(input)) return cachePercentB[idx]; - return CacheIndicator(new PercentB(){ Period = period, StandardDeviations = standardDeviations, UpperLevel = upperLevel, UpperLevelStroke = upperLevelStroke, LowerLevel = lowerLevel, LowerLevelStroke = lowerLevelStroke }, input, ref cachePercentB); + return CacheIndicator(new PercentB(){ Period = period, StandardDeviations = standardDeviations }, input, ref cachePercentB); } } } @@ -125,14 +121,14 @@ namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { - public Indicators.PercentB PercentB(int period, double standardDeviations, double upperLevel, Stroke upperLevelStroke, double lowerLevel, Stroke lowerLevelStroke) + public Indicators.PercentB PercentB(int period, double standardDeviations) { - return indicator.PercentB(Input, period, standardDeviations, upperLevel, upperLevelStroke, lowerLevel, lowerLevelStroke); + return indicator.PercentB(Input, period, standardDeviations); } - public Indicators.PercentB PercentB(ISeries input , int period, double standardDeviations, double upperLevel, Stroke upperLevelStroke, double lowerLevel, Stroke lowerLevelStroke) + public Indicators.PercentB PercentB(ISeries input , int period, double standardDeviations) { - return indicator.PercentB(input, period, standardDeviations, upperLevel, upperLevelStroke, lowerLevel, lowerLevelStroke); + return indicator.PercentB(input, period, standardDeviations); } } } @@ -141,14 +137,14 @@ namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { - public Indicators.PercentB PercentB(int period, double standardDeviations, double upperLevel, Stroke upperLevelStroke, double lowerLevel, Stroke lowerLevelStroke) + public Indicators.PercentB PercentB(int period, double standardDeviations) { - return indicator.PercentB(Input, period, standardDeviations, upperLevel, upperLevelStroke, lowerLevel, lowerLevelStroke); + return indicator.PercentB(Input, period, standardDeviations); } - public Indicators.PercentB PercentB(ISeries input , int period, double standardDeviations, double upperLevel, Stroke upperLevelStroke, double lowerLevel, Stroke lowerLevelStroke) + public Indicators.PercentB PercentB(ISeries input , int period, double standardDeviations) { - return indicator.PercentB(input, period, standardDeviations, upperLevel, upperLevelStroke, lowerLevel, lowerLevelStroke); + return indicator.PercentB(input, period, standardDeviations); } } }