The NT7 version of the Guppy MACD uses the term "set" to define in OnBarUpdate but NT8 doesn't use this. Ive been researching the problem but decided to come here after not having much luck.
namespace NinjaTrader.NinjaScript.Indicators
{
public class GuppyMACD : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "GuppyMACD";
Calculate = Calculate.OnBarClose;
IsOverlay = false;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = false;
DrawVerticalGridLines = false;
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;
Fast = 8;
Slow = 17;
Smooth = 9;
FFast = 7;
SSlow = 16;
SSmooth = 8;
FFFast = 6;
SSSlow = 15;
SSSmooth = 7;
HistoScale = 1;
AddPlot(Brushes.Orange, "MACD1Main");
AddPlot(Brushes.MistyRose, "MACD1Avg");
AddPlot(Brushes.DarkOrange, "MACD2Main");
AddPlot(Brushes.DodgerBlue, "MACD2Avg");
AddPlot(Brushes.Red, "MACD3Main");
AddPlot(Brushes.Chartreuse, "MACD3Avg");
AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Bar, "HistoUp");
AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Bar, "HistoDown");
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
//Add your custom indicator logic hereif( CurrentBar < 1 )
MACD1Main.Set( MACD( Fast, Slow, Smooth )[ 0 ] );
MACD1Avg.Set( MACD( Fast, Slow, Smooth ).Avg[ 0 ] );
MACD2Main.Set( MACD( FFast, SSlow, SSmooth )[ 0 ] );
MACD2Avg.Set( MACD( FFast, SSlow, SSmooth ).Avg[ 0 ] );
MACD3Main.Set( MACD( FFFast, SSSlow, SSSmooth )[ 0 ] );
MACD3Avg.Set( MACD( FFFast, SSSlow, SSSmooth ).Avg[ 0 ] );
double diff0 = MACD1Main[ 0 ] - MACD1Avg[ 0 ];
double diff1 = MACD1Main[ 1 ] - MACD1Avg[ 1 ];
if( diff0 >= diff1 )
HistoUp.Set( diff0 * HistoScale );
else
HistoDown.Set( diff0 * HistoScale );
}
#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Fast", Description="Number of bars for fast EMA", Order=1, GroupName="Parameters")]
public int Fast
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Slow", Description="Number of bars for slow EMA", Order=2, GroupName="Parameters")]
public int Slow
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Smooth", Description="Number of bars for smoothing", Order=3, GroupName="Parameters")]
public int Smooth
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="FFast", Description="Number of bars for fast EMA", Order=4, GroupName="Parameters")]
public int FFast
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="SSlow", Description="Number of bars for slow EMA", Order=5, GroupName="Parameters")]
public int SSlow
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="SSmooth", Description="Number of bars for smoothing", Order=6, GroupName="Parameters")]
public int SSmooth
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="FFFast", Order=7, GroupName="Parameters")]
public int FFFast
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="SSSlow", Order=8, GroupName="Parameters")]
public int SSSlow
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="SSSmooth", Order=9, GroupName="Parameters")]
public int SSSmooth
{ get; set; }
[NinjaScriptProperty]
[Range(1, double.MaxValue)]
[Display(Name="HistoScale", Description="Scale Histogram by factor x", Order=10, GroupName="Parameters")]
public double HistoScale
{ get; set; }
[Browsable(false)]
[XmlIgnore]
public Series<double> MACD1Main
{
get { return Values[0]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> MACD1Avg
{
get { return Values[1]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> MACD2Main
{
get { return Values[2]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> MACD2Avg
{
get { return Values[3]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> MACD3Main
{
get { return Values[4]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> MACD3Avg
{
get { return Values[5]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> HistoUp
{
get { return Values[6]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> HistoDown
{
get { return Values[7]; }
}
#endregion

Comment