ninjatrader/indicators/InternalBarStrength.cs

104 lines
3.2 KiB
C#

#region Using declarations
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using System.Windows.Media;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class InternalBarStrength : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Internal Bar Strength (IBS) Indicator";
Name = "Internal Bar Strength";
Calculate = Calculate.OnPriceChange;
IsOverlay = false;
DisplayInDataBox = true;
DrawOnPricePanel = true;
PaintPriceMarkers = true;
ScaleJustification = ScaleJustification.Right;
IsSuspendedWhileInactive = true;
AddPlot(new Stroke(Brushes.Yellow, DashStyleHelper.Solid, 3), PlotStyle.Line, "Internal Bar Strength");
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
if (High[0] == Low[0])
Value[0] = 0; // Prevent division by zero.
else
Value[0] = (Close[0] - Low[0]) / (High[0] - Low[0]);
}
public override string DisplayName
{
get { return Name; }
}
}
}
#region NinjaScript generated code. Neither change nor remove.
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private InternalBarStrength[] cacheInternalBarStrength;
public InternalBarStrength InternalBarStrength()
{
return InternalBarStrength(Input);
}
public InternalBarStrength InternalBarStrength(ISeries<double> input)
{
if (cacheInternalBarStrength != null)
for (int idx = 0; idx < cacheInternalBarStrength.Length; idx++)
if (cacheInternalBarStrength[idx] != null && cacheInternalBarStrength[idx].EqualsInput(input))
return cacheInternalBarStrength[idx];
return CacheIndicator<InternalBarStrength>(new InternalBarStrength(), input, ref cacheInternalBarStrength);
}
}
}
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.InternalBarStrength InternalBarStrength()
{
return indicator.InternalBarStrength(Input);
}
public Indicators.InternalBarStrength InternalBarStrength(ISeries<double> input )
{
return indicator.InternalBarStrength(input);
}
}
}
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.InternalBarStrength InternalBarStrength()
{
return indicator.InternalBarStrength(Input);
}
public Indicators.InternalBarStrength InternalBarStrength(ISeries<double> input )
{
return indicator.InternalBarStrength(input);
}
}
}
#endregion