Rename percent rank period parameter
This commit is contained in:
parent
c26a19a4c1
commit
f00b08c02c
@ -29,7 +29,7 @@ namespace NinjaTrader.NinjaScript.Indicators
|
|||||||
ScaleJustification = ScaleJustification.Right;
|
ScaleJustification = ScaleJustification.Right;
|
||||||
IsSuspendedWhileInactive = true;
|
IsSuspendedWhileInactive = true;
|
||||||
|
|
||||||
PercentRankPeriod = 100;
|
Period = 100;
|
||||||
|
|
||||||
AddPlot(new Stroke(Brushes.Yellow, 3), PlotStyle.Line, "Percent Rank");
|
AddPlot(new Stroke(Brushes.Yellow, 3), PlotStyle.Line, "Percent Rank");
|
||||||
}
|
}
|
||||||
@ -43,13 +43,13 @@ namespace NinjaTrader.NinjaScript.Indicators
|
|||||||
{
|
{
|
||||||
inputs.Add(Input[0]);
|
inputs.Add(Input[0]);
|
||||||
|
|
||||||
if (CurrentBar < PercentRankPeriod)
|
if (CurrentBar < Period)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int rank = inputs.Count(input => input < Input[0]);
|
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);
|
inputs.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +59,8 @@ namespace NinjaTrader.NinjaScript.Indicators
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NinjaScriptProperty]
|
[NinjaScriptProperty]
|
||||||
[Display(Name = "Percent Rank Period", GroupName = "Percent Rank", Order = 1)]
|
[Display(Name = "Period", GroupName = "Percent Rank", Order = 1)]
|
||||||
public int PercentRankPeriod { get; set; }
|
public int Period { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,18 +71,18 @@ namespace NinjaTrader.NinjaScript.Indicators
|
|||||||
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
|
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
|
||||||
{
|
{
|
||||||
private PercentRank[] cachePercentRank;
|
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<double> input, int percentRankPeriod)
|
public PercentRank PercentRank(ISeries<double> input, int period)
|
||||||
{
|
{
|
||||||
if (cachePercentRank != null)
|
if (cachePercentRank != null)
|
||||||
for (int idx = 0; idx < cachePercentRank.Length; idx++)
|
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 cachePercentRank[idx];
|
||||||
return CacheIndicator<PercentRank>(new PercentRank(){ PercentRankPeriod = percentRankPeriod }, input, ref cachePercentRank);
|
return CacheIndicator<PercentRank>(new PercentRank(){ Period = period }, input, ref cachePercentRank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,14 +91,14 @@ namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
|
|||||||
{
|
{
|
||||||
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
|
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<double> input , int percentRankPeriod)
|
public Indicators.PercentRank PercentRank(ISeries<double> 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 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<double> input , int percentRankPeriod)
|
public Indicators.PercentRank PercentRank(ISeries<double> input , int period)
|
||||||
{
|
{
|
||||||
return indicator.PercentRank(input, percentRankPeriod);
|
return indicator.PercentRank(input, period);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user