Had a client running live today using an indicator I wrote.
The client hit f5 and noticed the indicator values were changed to incorrect values after the chart updated.
Took a while but I tracked it down and wrote a simple indicator that reproduces the issue.
1. No history. The client is running realtime, and no history was saved for the current day nor the previous day.
2. Primary series is 5-minute candles, secondary series is one-minute candles.
I'm using the playback connection with a start date of 02/05/2020 and an end date of 02/06/2020. ES 03-20 contract. Once again, no history, the only data I have for the two days are the downloaded replay files.
Set up the chart with a data series end date of 02/06/20 and days to load set to 2. Chart starts off completely empty since there is no history to backfill from.
Start the replay, I use max playback speed. Pause the playback around ~9:40 on 02/06/2020 Hit f5. At this point my indicator plotted at incorrect price levels.
On the refresh, NT only provides the internal minute bars starting at 02/06/2020 12:01:am. So the minute bars from 02/05/2020 are not sent to the indicator when refreshing with f5. The missing one-minute bars from 02/05/2020 cause my indicator to calculate incorrect values.
So here is an example of logging when running the playback. Getting the secondary series one-minute bars for both 02/05/2020 and 02/06/2020 as expected:
Raw obu: 2/5/2020 11:55:00 PM
Prim bars called: 2/5/2020 11:55:00 PM Current Bar: 271
Raw obu: 2/5/2020 11:55:00 PM
2nd series (min) bars called: 2/5/2020 11:55:00 PM Current Bar: 1359 Prim CB: 271
Raw obu: 2/5/2020 11:56:00 PM
2nd series (min) bars called: 2/5/2020 11:56:00 PM Current Bar: 1360 Prim CB: 271
Raw obu: 2/5/2020 11:57:00 PM
2nd series (min) bars called: 2/5/2020 11:57:00 PM Current Bar: 1361 Prim CB: 271
Raw obu: 2/5/2020 11:58:00 PM
2nd series (min) bars called: 2/5/2020 11:58:00 PM Current Bar: 1362 Prim CB: 271
Raw obu: 2/5/2020 11:59:00 PM
2nd series (min) bars called: 2/5/2020 11:59:00 PM Current Bar: 1363 Prim CB: 271
Raw obu: 2/6/2020 12:00:00 AM
Prim bars called: 2/6/2020 12:00:00 AM Current Bar: 272
Raw obu: 2/6/2020 12:00:00 AM
2nd series (min) bars called: 2/6/2020 12:00:00 AM Current Bar: 1364 Prim CB: 272
Raw obu: 2/6/2020 12:01:00 AM
2nd series (min) bars called: 2/6/2020 12:01:00 AM Current Bar: 1365 Prim CB: 272
Raw obu: 2/6/2020 12:02:00 AM
2nd series (min) bars called: 2/6/2020 12:02:00 AM Current Bar: 1366 Prim CB: 272
This is the log after pausing the replay and pressing f5, note I don't receive any of the secondary bars for 02/05/2020. It's not until 02/06/2020 that the secondary one-minute bars start coming in. Seems unexpected. My indicator uses the prior day's data as part of it's calculation, and the missing data is throwing it off.
Raw obu: 2/5/2020 11:50:00 PM
Prim bars called: 2/5/2020 11:50:00 PM Current Bar: 270
Raw obu: 2/5/2020 11:55:00 PM
Prim bars called: 2/5/2020 11:55:00 PM Current Bar: 271
Raw obu: 2/6/2020 12:00:00 AM
Prim bars called: 2/6/2020 12:00:00 AM Current Bar: 272
Raw obu: 2/6/2020 12:01:00 AM
2nd series (min) bars called: 2/6/2020 12:01:00 AM Current Bar: 0 Prim CB: 272
Raw obu: 2/6/2020 12:02:00 AM
2nd series (min) bars called: 2/6/2020 12:02:00 AM Current Bar: 1 Prim CB: 272
Raw obu: 2/6/2020 12:03:00 AM
2nd series (min) bars called: 2/6/2020 12:03:00 AM Current Bar: 2 Prim CB: 272
If there is history available for 02/05/2020 and 02/06/2020 the issue goes away.
Here is a very simple indicator that adds the secondary data series and does the logging:
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class RtNoHistoryTest : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Simple indicator to reproduce refreshing a multitimeframe chart that does not have any backing historu";
Name = "RtNoHistoryTest";
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 = false;
}
else if (State == State.Configure)
{
// Force calc back to onbarclose if user tries to change
Calculate = Calculate.OnBarClose;
// Add one minute data series
AddDataSeries(BarsPeriodType.Minute, 1);
}
}
protected override void OnBarUpdate()
{
Print("Raw obu: " + Time[0]);
if (BarsInProgress == 1)
{
Print("2nd series (min) bars called: " + Time[0] + " Current Bar: " + CurrentBars[1] + " Prim CB: " + CurrentBars[0]);
}
if (BarsInProgress == 0)
{
Print("Prim bars called: " + Time[0] + " Current Bar: " + CurrentBars[0]);
}
Print("");
}
}
}

Comment