I am creating an indicator that references another indicator. I got it working, and it did just what I wanted it to.
Then I restarted ninja and BAM!!! I get the error shown in the picture.
It compiles fine, but I get the error and the indicator just won't plot.
The error I am getting seems to be related to THIS thread HERE. I really don't understand the problem?
My code snippet is below, and it seems the problem lies in the initialization of the dataseries I have called "swingRelation." I've commented everything else out in the void onBarUpdate block, and the problem occurs when I get to that condition that deals with that data series.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
[Description("This indicator kicks the market's ass")]
public class FPCJTrend : Indicator
{
#region Variables
//#####################################################################
//Variables for PriceActionSwing
private int swingSize = 2;
private SwingTypes swingType = SwingTypes.Standard;
private int dtbStrength = 15;
private IDataSeries swingRelation = null;
private IDataSeries swingTrend;
private bool seeRelation = false;
private bool useOldTrend = true;
private bool paintBars = true;
private int oldTrend = 0;
private Color upTrendColour = Color.Green;
private Color dnTrendColour = Color.Red;
private Color noTrendColour = Color.Gray;
//Variables for IchiCloud
private int periodFast = 9; // Default setting for PeriodFast
private int periodMedium = 26; // Default setting for PeriodMedium
private int periodSlow = 52; // Default setting for PeriodSlow
//Variables independant to FPCJTrend
private bool blueCloud = false;
private bool redCloud = false;
private int ichiBuffer = 6;
//#####################################################################
#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(new Pen(Color.Firebrick, 20), PlotStyle.Square, "DoubleTop"));
Add(new Plot(new Pen(Color.Red, 20), PlotStyle.Square, "DownTrend"));
Add(new Plot(new Pen(Color.Gold, 20), PlotStyle.Square, "NoWhere"));
Add(new Plot(new Pen(Color.Green, 20), PlotStyle.Square, "UpTrend"));
Add(new Plot(new Pen(Color.Lime, 20), PlotStyle.Square, "DoubleBottom"));
CalculateOnBarClose = true;
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
//if (CurrentBar < swingSize)
//return; //Do we have enough bars for PriceActionSwing
//if ((CurrentBar < periodMedium) || (CurrentBar < periodFast))
//return; // Do we have enough bars for Ichi Calculation
if (CurrentBar < 1)
{
if (swingRelation == null && seeRelation)
swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;
if (swingTrend == null && !seeRelation)
swingTrend = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingTrend;
}
double spanA = IchiCloud(Input, periodFast, periodMedium, periodSlow).SenkouSpanA[0];
double spanB = IchiCloud(Input, periodFast, periodMedium, periodSlow).SenkouSpanB[0];
if(spanA > spanB)
{
blueCloud = true;
redCloud = false;
}
if(spanA < spanB)
{
redCloud = true;
blueCloud = false;
}
/*
if(redCloud == true)
{
DrawArrowDown("arrow"+CurrentBar, true, 0, Low[0]+12*TickSize, Color.Red);
}
//Print(redCloud);
*/
///*
if (swingRelation[0] == 1 && blueCloud == true && Low[0] > spanA-ichiBuffer*TickSize)
{
//UpTrend.Set(Close[0]);
//DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
//Print("hi");
}
else if (swingRelation[0] == -1 && redCloud == true && High[0] < spanA+ ichiBuffer*TickSize)
{
//DownTrend.Set(1);
//DrawArrowDown("arrow"+CurrentBar, true, 0, Low[0]+12*TickSize, Color.Red);
}
else
{
//NoWhere.Set(1);
}
............

Comment