Previous release of NT have same issue. But i didn't report it before and i solved my issue in various ways. But with NT8 i don't want to do anymore. My opinion its a bug but of course i'm not sure.
Reproduce issue below steps (Also i will attach sample codes and 2 screenshots);
1. Write an indicator that plot some data overlay on price panel and need bars number below 20. Only for example indicator can be calculate support and resistance levels with only to use current bar values. This means this indicator's "BarsRequiredToPlot" property can be 0 (like i said below 20) because of there is no need to use any previous bar's data.
2. Write a strategy that doing nothing in terms of trading because there is no need for reproduce issue. Only do below steps;
2.1. Create private variable for indicator.
private SupResLevels supResLevels;
2.2. Add/Change below lines to OnStateChage -> SetDefaults.
BarsRequiredToTrade = 1; // There is no need bigger value about it
AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Hash, "Support");
AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "Resistance");
2.3. Add below lines to OnStateChage -> Configure.
AddDataSeries(Instrument.FullName, new BarsPeriod() { MarketDataType = BarsPeriod.MarketDataType, BarsPeriodType = BarsPeriod.BarsPeriodType, Value = BarsPeriod.Value * 10}, Instrument.MasterInstrument.TradingHours.Name, null);
2.4. Add below codes to OnBarUpdate.
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < BarsRequiredToTrade ||
CurrentBars[1] < BarsRequiredToTrade)
{
return;
}
if (supResLevels == null)
{
supResLevels = SupResLevels(BarsArray[1]);
}
Support[0] = supResLevels.Support[1];
Resistance[0] = supResLevels.Resistance[1];
3. Connect to market replay and open a chart for X instruments X TimePeriod. I used "ES 03-17" and 4 ticks renko chart. So our secondary data will be "ES 03-17" and 40 ticks renko. You will see these is NaN and -0- plots on a chart. Warning!!! you have to load data on a chart below 20 bar number for higher time frame for see the problem. It does not matter market replay is at first available date or working or not.
Shortly i'm saying that to NT8; For Indicator calculation you can start from first bar, for strategy calculations you can start from second bar. But NT don't worry about these values and always trying to use 20 and because of we don't have enough bar for 40 ticks renko chart it will plot nonsense values to a chart.
How can i solve this issue? I'm adding below code to a indicators OnStateChange method and set it BarsRequiredToPlot to zero again like State.SetDefaults;
else if (State == State.Historical)
{
BarsRequiredToPlot = 0;
}
Question is why i have to set BarsRequiredToPlot to zero in many states, even i set it at state SetDefaults? If i set it to zero in SetDefaults, so my opinion it's default for all states (no matter real time, historical etc.) and can not be change/override in any stuation(even NT can not) and only programmer can be override defaults.
Regards,
Aytac
Comment