It took me quite some time but I managed to migrate my complete trading setup (including all custom indicators and strategies) from NT 6.5 to NT 7.
The only indicator that doesn't work is the following: (NT Log says: Failed to call method "Initialize" for indicator MASlope: "BarsInProgress" property can not be accessed from within "Initialize" method.
Could someone please point me in the right direction, thanks a lot.
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
[Description("Enter the description of your new custom indicator here")]
public class MASlope : Indicator
{
#region Variables
private int numPeriods = 50;
private SMA smaperiod;
private int period = 200;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Black, "Short Term Slope"));
Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "ZERO"));
Add(new Line(Color.FromKnownColor(KnownColor.Red), 10, "PLUS10")); // References +10,-10, ZERO
Add(new Line(Color.FromKnownColor(KnownColor.Red), -10, "MINUS10"));
PriceTypeSupported = true;
smaperiod = SMA(period);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
double slope = Math.Atan(Slope(smaperiod, numPeriods,0)) * 180/Math.PI;
Short.Set(slope);
}
#region Properties
[Browsable(false)]
[XmlIgnore()]
public DataSeries Short
{
get { return Values[0]; }
}
[Description("Number of Periods to Gather Slope Across")]
[Category("Parameters")]
[Gui.Design.DisplayNameAttribute("# of periods")]
public int NumPeriods
{
get { return numPeriods; }
set { numPeriods = Math.Max(1, value); }
}
[Description("The SMA to derive the slope from")]
[Category("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
#endregion
}
}

Comment