I am translating into Ninjatrader7 an open source indicator designed for NT8. I usually convert the other way around but I need this one also for NT7 during the upgrade transition.
At Line 35 at the 'Indicator' inheritance of the class definition I am getting
'NinjaTrader.Indicator' is a 'namespace' but is used like a 'type' at the class definition ( and later in the cache code says The type or namespace name 'AuHoltEMA' could not be found (are you missing a using directive or an assembly reference?)
Can someone see what the problem is?
Thank you!
G
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.Indicators
{
/// <summary>
/// Exponential Moving Average.
/// </summary>
[Description("")]
public class AuHoltEMA : Indicator
{
#region Variables
private int period = 89;
private int trendPeriod = 144;
private double alpha = 0.0; // Default setting for Alpha
private double gamma = 0.0; // Default setting for Gamma
//private DataSeries trend;
private bool showPaintBars = true;
private Brush upColor = Brushes.Lime;
private Brush neutralColor = Brushes.Tan;
private Brush downColor = Brushes.Red;
private int opacity = 4;
private int alphaBarClr = 0;
private bool showPlot = true;
#endregion
protected override void Initialize()
{
Description = @"http://www2.gsu.edu/~dscthw/8110/Chapter8.pdf";
Name = "AuHoltEMA";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
ShowTransparentPlotsInDataBox = true;
AddPlot(new Stroke(Brushes.DodgerBlue, 2), PlotStyle.Line, "HoltEMA");
AddPlot(new Stroke() { Brush = Brushes.Transparent, Width = 1, DashStyleHelper = DashStyleHelper.Solid }, PlotStyle.Dot, "HoltEMATrend");
Trend = new DataSeries(this);
}
protected override void OnBarUpdate()
{
double alpha = 2.0 / (1 + Period);
double gamma = 2.0 / (1 + TrendPeriod);
//OnStartup
if (CurrentBar < 1)
{
alphaBarClr = 25 * opacity;
if (showPlot)
Plots[0].Brush = Brushes.Gray;
else
Plots[0].Brush = Brushes.Transparent;
HoltEMA[0] = Input[0];
Trend[0] = 0.0;
return;
}
else
{
double holt = alpha * Input[0] + (1 - alpha) * (HoltEMA[1] + Trend[1]);
HoltEMA[0] = holt;
Trend[0] = gamma * (holt - HoltEMA[1]) + (1 - gamma) * Trend[1];
}
if (CurrentBar > 1)
{
HoltEMATrend[0] = 0;
if (HoltEMA[0] > HoltEMA[1])
HoltEMATrend[0] = 1;
else if (HoltEMA[0] < HoltEMA[1])
HoltEMATrend[0] = -1;
if (showPlot)
{
if (HoltEMATrend[0] == 1)
PlotBrushes[0][0] = upColor;
else if (HoltEMATrend[0] == -1)
PlotBrushes[0][0] = downColor;
else if (HoltEMATrend[0] == 0)
PlotBrushes[0][0] = neutralColor;
}
if (showPaintBars)
{
if (HoltEMATrend[0] == 1)
{
BarBrushes[0] = upColor;
CandleOutlineBrushes[0] = upColor;
}
else if (HoltEMATrend[0] == -1)
{
BarBrushes[0] = downColor;
CandleOutlineBrushes[0] = downColor;
}
else
{
BarBrushes[0] = neutralColor;
CandleOutlineBrushes[0] = neutralColor;
}
if (Close[0] > Open[0])
{
byte g = ((Color)BarBrushes[0].GetValue(SolidColorBrush.ColorProperty)).G;
byte r = ((Color)BarBrushes[0].GetValue(SolidColorBrush.ColorProperty)).R;
byte b = ((Color)BarBrushes[0].GetValue(SolidColorBrush.ColorProperty)).B;
BarBrushes[0] = new SolidColorBrush(Color.FromArgb((byte)alphaBarClr, r, g, b));
}
}
}
}
#region Properties
//[Browsable(false)]
//[XmlIgnore]
//public Series<double> HoltEMA
//{
// get { return Values[0]; }
//}
//
//[Browsable(false)]
//[XmlIgnore]
//public Series<double> HoltEMATrend
//{
// get { return Values[1]; }
//}
//
//[Browsable(false)]
//[XmlIgnore]
//public Series<double> Trend
//{
// get { return trend; }
//}
//}
[Browsable(false)] [XmlIgnore()] public DataSeries HoltEMA { get; protected set; } //MP- Added
[Browsable(false)] [XmlIgnore()] public DataSeries HoltEMATrend { get; protected set; } //MP- Added
[Browsable(false)] [XmlIgnore()] public DataSeries Trend { get; protected set; } //MP- Added
//[NinjaScriptProperty]
//[Display(Name = "Period", Description = "Period", Order = 0, GroupName = "Gen. Parameters")]
[Category("Parameters")]
public int Period
{
get { return period; }
set { period = period = Math.Max(1, value); }
}
//[NinjaScriptProperty]
//[Display(Name = "Trend Period", Description = "Trend Period", Order = 1, GroupName = "Gen. Parameters")]
[Category("Parameters")]
public int TrendPeriod
{
get { return trendPeriod; }
set { trendPeriod = Math.Max(1, value); }
}
//[Display(Name = "Show PaintBars", Description = "Show paint bars on price panel", Order = 2, GroupName = "Gen. Parameters")]
[Category("Plot Colors")]
public bool ShowPaintBars
{
get { return showPaintBars; }
set { showPaintBars = value; }
}
[XmlIgnore]
//[Display(Name = "Average Chop Mode", Description = "Select color for neutral average", Order = 0, GroupName = "Plot Colors")]
[Category("Plot Colors")]
public Brush NeutralColor
{
get { return neutralColor; }
set { neutralColor = value; }
}
[Browsable(false)]
public string NeutralColorSerialize
{
get { return Serialize.BrushToString(neutralColor); }
set { neutralColor = Serialize.StringToBrush(value); }
}
[XmlIgnore]
//[Display(Name = "Average Falling", Description = "Select color for falling average", Order = 1, GroupName = "Plot Colors")]
[Category("Plot Colors")]
public Brush DownColor
{
get { return downColor; }
set { downColor = value; }
}
[Browsable(false)]
public string DownColorSerialize
{
get { return Serialize.BrushToString(downColor); }
set { downColor = Serialize.StringToBrush(value); }
}
[XmlIgnore]
//[Display(Name = "Average Rising", Description = "Select color for rising average", Order = 2, GroupName = "Plot Colors")]
[Category("Plot Colors")]
public Brush UpColor
{
get { return upColor; }
set { upColor = value; }
}
[Browsable(false)]
public string UpColorSerialize
{
get { return Serialize.BrushToString(upColor); }
set { upColor = Serialize.StringToBrush(value); }
}
//[Display(Name = "Upclose Opacity", Description = "When paint bars are activated, this parameter sets the opacity of the upclose bars", Order = 3, GroupName = "Plot Colors")]
[Category("Plot Colors")]
public int Opacity
{
get { return opacity; }
set { opacity = value; }
}
//[Display(Name = "Show Plot", Description = "Show plot of the Zero-Lagging Heiken-Ashi TEMA", Order = 4, GroupName = "Plot Colors")]
[Category("Plot Colors")]
public bool ShowPlot
{
get { return showPlot; }
set { showPlot = value; }
}
#endregion
}
}

Comment