This is probably both an indicator development and a platform support issue.
I have used the advice in this now closed thread to plot an existing indicator in another indicator and also a secondary series of this indicator. The original indicator takes less than 5 seconds to load to a chart, but the new indicator is taking at least 5 minutes, even when I comment out the secondary series. If I use the 32bit version of NT8, it often runs out of memory whilst trying to load the indicator and crashes. If I use the 62bit version of NT8 it takes about 5MINs to load or offload the indicator to or from a chart - this thread deals with the memory hogging problem with NT8. In addition, the secondary series plot has gaps in it, despite me setting it in if (BarsInProgress == 0), which I was advised in this thread should stop the gaps.
Now I am able to create both plots to the chart using another method, that is to open a second hidden data series on a chart and load the source indicator a second time using the second data series, and that works fine, but I think that will eventually use up too much RAM and CPU, as the second data series although hidden is still running in the background.
Is there anything I can do to clean up my indicator to make it load faster, and also to stop the gaps from appearing in the secondary series plots? I have inserted the code below.
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class My2ndDataSeriesPlots : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Plots based on primary data series and a second plot based on secondary dataseries";
Name = "My2ndDataSeriesPlots";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Left;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = false;
Period = 14;
SecondaryDataSeriesValue = 36;
AddPlot(new Stroke(Brushes.Red,3), PlotStyle.Line, "PrimaryOS"); // Defines the plot for Values[0]
AddPlot(new Stroke(Brushes.DarkBlue,3), PlotStyle.Line, "PrimaryOB"); // Defines the plot for Values[1]
AddPlot(new Stroke(Brushes.Magenta, 3), PlotStyle.Hash, "SecondaryOS"); // Defines the plot for Values[2]
AddPlot(new Stroke(Brushes.Green, 3), PlotStyle.Hash, "SecondaryOB"); // Defines the plot for Values[3]
}
else if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Tick, SecondaryDataSeriesValue);
}
else if (State == State.DataLoaded)
{
Name = ""; //See State == State.SetDefaults to set name so it appears in indicator list
}
else if (State == State.Historical)
{
// Make sure our object plots above the chart bars
SetZOrder(int.MaxValue);
}
}
protected override void OnBarUpdate()
{
// Checks if OnBarUpdate() is called from an update on the primary Bars - because added a 15M dataseries 21/01/2017
if (BarsInProgress == 0)
{
// Use this method for calculating your indicator values. Assign a value to each
if (CurrentBars[0] <= BarsRequiredToPlot || CurrentBars[1] <= BarsRequiredToPlot)
{
return;
}
Values[0][0] = (MyBuySell05BearBull(14, 4, 0.8, 0.2, 0.98).BslShortPeriodBear[0]);
Values[1][0] = (MyBuySell05BearBull(14, 4, 0.8, 0.2, 0.98).BslShortPeriodBull[0]);
Values[2][0] = (MyBuySell05BearBull((BarsArray[1]), 14, 4, 0.8, 0.2, 0.98).BslShortPeriodBear[0]);
Values[3][0] = (MyBuySell05BearBull((BarsArray[1]), 14, 4, 0.8, 0.2, 0.98).BslShortPeriodBull[0]);
}
}
#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Period", Description="Default moving average period", Order=1, GroupName="Parameters")]
public int Period
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="SecondaryDataSeriesValue", Description="Value for Secondary data series", Order=2, GroupName="Parameters")]
public int SecondaryDataSeriesValue
{ get; set; }
[Browsable(false)]
[XmlIgnore]
public Series<double> PrimaryOS
{
get { return Values[0]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> PrimaryOB
{
get { return Values[1]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> SecondaryOS
{
get { return Values[2]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> SecondaryOB
{
get { return Values[3]; }
}
#endregion

Comment