wheelsofsteel2 wrote:
Q2: The IBar (bars & bars2) do not exactly match the values for the previous DAILY bar on the chart. Is my code incorrect and can you suggest a better/correct way of retrieving the previous DAILY bar? prevBar is commented out as it's values are way off what I observe on the chart.
Try to create custom Daily period and filter Weekends to avoid zero periods:
Period custom_daily = Period.createCustomPeriod(Unit.Day, 1, JFTimeZone.EET);
double pivot[][] = indicators.pivot(instrument, chart_period, OfferSide.BID, custom_daily,
Filter.WEEKENDS, 1, context.getHistory().getBar(instrument, custom_daily, OfferSide.BID, 0).getTime(), 0);
Hope it helps, because this problem is about all Daily calculations, not only pivot but ATR etc.