From f00b08c02cd43621976e8ddb42ac45052f57c232 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 9 Jan 2025 08:28:55 -0800 Subject: [PATCH] Rename percent rank period parameter --- indicators/percent-rank/PercentRank.cs | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/indicators/percent-rank/PercentRank.cs b/indicators/percent-rank/PercentRank.cs index 83a86ce..4f9d618 100644 --- a/indicators/percent-rank/PercentRank.cs +++ b/indicators/percent-rank/PercentRank.cs @@ -29,7 +29,7 @@ namespace NinjaTrader.NinjaScript.Indicators ScaleJustification = ScaleJustification.Right; IsSuspendedWhileInactive = true; - PercentRankPeriod = 100; + Period = 100; AddPlot(new Stroke(Brushes.Yellow, 3), PlotStyle.Line, "Percent Rank"); } @@ -43,13 +43,13 @@ namespace NinjaTrader.NinjaScript.Indicators { inputs.Add(Input[0]); - if (CurrentBar < PercentRankPeriod) + if (CurrentBar < Period) return; int rank = inputs.Count(input => input < Input[0]); - Value[0] = (double)rank / PercentRankPeriod * 100; + Value[0] = (double)rank / Period * 100; - if (inputs.Count > PercentRankPeriod) + if (inputs.Count > Period) inputs.RemoveAt(0); } @@ -59,8 +59,8 @@ namespace NinjaTrader.NinjaScript.Indicators } [NinjaScriptProperty] - [Display(Name = "Percent Rank Period", GroupName = "Percent Rank", Order = 1)] - public int PercentRankPeriod { get; set; } + [Display(Name = "Period", GroupName = "Percent Rank", Order = 1)] + public int Period { get; set; } } } @@ -71,18 +71,18 @@ namespace NinjaTrader.NinjaScript.Indicators public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private PercentRank[] cachePercentRank; - public PercentRank PercentRank(int percentRankPeriod) + public PercentRank PercentRank(int period) { - return PercentRank(Input, percentRankPeriod); + return PercentRank(Input, period); } - public PercentRank PercentRank(ISeries input, int percentRankPeriod) + public PercentRank PercentRank(ISeries input, int period) { if (cachePercentRank != null) for (int idx = 0; idx < cachePercentRank.Length; idx++) - if (cachePercentRank[idx] != null && cachePercentRank[idx].PercentRankPeriod == percentRankPeriod && cachePercentRank[idx].EqualsInput(input)) + if (cachePercentRank[idx] != null && cachePercentRank[idx].Period == period && cachePercentRank[idx].EqualsInput(input)) return cachePercentRank[idx]; - return CacheIndicator(new PercentRank(){ PercentRankPeriod = percentRankPeriod }, input, ref cachePercentRank); + return CacheIndicator(new PercentRank(){ Period = period }, input, ref cachePercentRank); } } } @@ -91,14 +91,14 @@ namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { - public Indicators.PercentRank PercentRank(int percentRankPeriod) + public Indicators.PercentRank PercentRank(int period) { - return indicator.PercentRank(Input, percentRankPeriod); + return indicator.PercentRank(Input, period); } - public Indicators.PercentRank PercentRank(ISeries input , int percentRankPeriod) + public Indicators.PercentRank PercentRank(ISeries input , int period) { - return indicator.PercentRank(input, percentRankPeriod); + return indicator.PercentRank(input, period); } } } @@ -107,14 +107,14 @@ namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { - public Indicators.PercentRank PercentRank(int percentRankPeriod) + public Indicators.PercentRank PercentRank(int period) { - return indicator.PercentRank(Input, percentRankPeriod); + return indicator.PercentRank(Input, period); } - public Indicators.PercentRank PercentRank(ISeries input , int percentRankPeriod) + public Indicators.PercentRank PercentRank(ISeries input , int period) { - return indicator.PercentRank(input, percentRankPeriod); + return indicator.PercentRank(input, period); } } }