I want to pass along a situation and workaround that can happen when loading additional MultiBarArray's.
When a chart is configured to contain an Indicator A whose source is another Indicator B whose source is Instrument I. And if Indicator B calls AddDataSeries(), then "BarsToLoad" for that series appears to be forever locked to the initial value of Instrument I's BarsToLoad.
The problem comes along if the BarsToLoad is increased using the Chart Control. When that happens the BarsArray[1] within Indicator B does not load enough bars. The workaround below appears to be working but I'm not sure that "PriceSeries.Count" is the best way to determine the value of BarsToLoad that was set within the interface.
A better fix may be for NT8 to preserve the "BarsToLoad" within Indicators that are sources of other Indicators, especially when additional DataSeries() are added.
Hope this can help someone else or encourage a fix,
Thanks,
Chris
case State.Configure:
BarsRequiredToPlot = 1;
// If an indicator is used as source for another indicator, and then later on
// the BarsToLoad is increased for the original instrument, The AddDataSeries() below and
// BarsToLoad in this indicator fail to track the BarsToLoad change.
//
int? forceBarsToLoad = null;
string tradingHours = null;
PriceSeries priceSeriesInput = Input as PriceSeries;
if (priceSeriesInput.Count > BarsToLoad)
{
forceBarsToLoad = BarsToLoad = priceSeriesInput.Count;
tradingHours = priceSeriesInput.Bars.TradingHours.Name;
}
string partnerInstrument = "^DECL"; // assumes main instrument is "^ADV"
BarsPeriod barsPeriod = new BarsPeriod() { BarsPeriodType = BarsPeriod.BarsPeriodType, Value = BarsPeriod.Value };
if (forceBarsToLoad.HasValue)
{
if (tradingHours == null)
tradingHours = "US Equities RTH";
AddDataSeries(partnerInstrument, barsPeriod, forceBarsToLoad.Value, tradingHours, false); // BA[1]
}
else
{
AddDataSeries(partnerInstrument, BarsPeriod.BarsPeriodType, BarsPeriod.Value); // BA[1]
}
break;
Comment