The Chart is a Daily Chart using NT's EOD Stock Data the Secondary series a Weekly Series. I choose this to keep things a simple as possible.
public class tajTestMTF : Indicator
{
private Series<int> Series_WeekBarNumber;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "tajTestMTF";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
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;
}
else if (State == State.Configure)
{
ClearOutputWindow();
AddDataSeries(Data.BarsPeriodType.Week, 1);
}
else if (State == State.DataLoaded)
{
Series_WeekBarNumber = new Series<int>(BarsArray[1], MaximumBarsLookBack.Infinite);
}
}
protected override void OnBarUpdate()
{
if(BarsInProgress == 0)
{
Print(string.Format("{0,9} Primary Bar Number: {1,4} Secondary Bar Number: {2,4} ValidDataPoint: {3}",
Time[0].DayOfWeek,
CurrentBar,
Series_WeekBarNumber[0],
Series_WeekBarNumber.IsValidDataPointAt(CurrentBars[1])
));
if(Times[0][0].DayOfWeek == DayOfWeek.Friday)
Print("----------------------------------------------");
}
if(BarsInProgress == 1)
{
if(CurrentBar >= 0)
Series_WeekBarNumber[0] = CurrentBar;
}
}
}
Thursday Primary Bar Number: 2507 Secondary Bar Number: 521 ValidDataPoint: True
Friday Primary Bar Number: 2508 Secondary Bar Number: 0 ValidDataPoint: False
----------------------------------------------
Monday Primary Bar Number: 2509 Secondary Bar Number: 522 ValidDataPoint: True
Tuesday Primary Bar Number: 2510 Secondary Bar Number: 522 ValidDataPoint: True
Wednesday Primary Bar Number: 2511 Secondary Bar Number: 522 ValidDataPoint: True
Thursday Primary Bar Number: 2512 Secondary Bar Number: 522 ValidDataPoint: True
Friday Primary Bar Number: 2513 Secondary Bar Number: 0 ValidDataPoint: False
----------------------------------------------
Monday Primary Bar Number: 2514 Secondary Bar Number: 523 ValidDataPoint: True
Tuesday Primary Bar Number: 2515 Secondary Bar Number: 523 ValidDataPoint: True
Wednesday Primary Bar Number: 2516 Secondary Bar Number: 523 ValidDataPoint: True
Thursday Primary Bar Number: 2517 Secondary Bar Number: 523 ValidDataPoint: True
Friday Primary Bar Number: 2518 Secondary Bar Number: 0 ValidDataPoint: False
----------------------------------------------
Monday Primary Bar Number: 2519 Secondary Bar Number: 524 ValidDataPoint: True
Tuesday Primary Bar Number: 2520 Secondary Bar Number: 524 ValidDataPoint: True
Wednesday Primary Bar Number: 2521 Secondary Bar Number: 524 ValidDataPoint: True
Thursday Primary Bar Number: 2522 Secondary Bar Number: 524 ValidDataPoint: True
Friday Primary Bar Number: 2523 Secondary Bar Number: 0 ValidDataPoint: False
----------------------------------------------
Monday Primary Bar Number: 2524 Secondary Bar Number: 525 ValidDataPoint: True
Tuesday Primary Bar Number: 2525 Secondary Bar Number: 525 ValidDataPoint: True
Wednesday Primary Bar Number: 2526 Secondary Bar Number: 525 ValidDataPoint: True
Thursday Primary Bar Number: 2527 Secondary Bar Number: 525 ValidDataPoint: True
Friday Primary Bar Number: 2528 Secondary Bar Number: 0 ValidDataPoint: False
----------------------------------------------
Monday Primary Bar Number: 2529 Secondary Bar Number: 526 ValidDataPoint: True
Tuesday Primary Bar Number: 2530 Secondary Bar Number: 526 ValidDataPoint: True
Wednesday Primary Bar Number: 2531 Secondary Bar Number: 526 ValidDataPoint: True
Thursday Primary Bar Number: 2532 Secondary Bar Number: 526 ValidDataPoint: True
Friday Primary Bar Number: 2533 Secondary Bar Number: 0 ValidDataPoint: False
----------------------------------------------
So the question is why on Fridays is the Secondary Bar Number always 0. Shouldn't that number be the same as the Thursday number?
If I read the Help Guide correctly when the Primary and Secondary have the same DateTime Stamp which they will on Friday's then the Primary is processed first which means the Secondary Bar number has not been updated and should be the same as the preceding Thursday. Only after the BIP[1] has been processed then the Series_WeekBarNumber should be updated and reflected on the following Monday.
Where am I going wrong?
Thanks.
Comment