You could do something like this (see full source in attachments):
public class PivotShiftVsCandleIntervalNew implements IStrategy {
private IConsole console;
private IIndicators indicators;
private IHistory history;
@Configurable("")
public Instrument instrument = Instrument.EURUSD;
@Configurable("")
public Period period = Period.FOUR_HOURS;
@Configurable("")
public Set<Period> timePeriods = new LinkedHashSet<Period>(Arrays.asList(new Period[]{Period.DAILY, Period.WEEKLY, Period.MONTHLY}));
@Configurable("")
public OfferSide side = OfferSide.BID;
@Configurable("")
public int barCount = 3;
private String[] pivotLevelNames;
public void onStart(IContext context) throws JFException {
this.console = context.getConsole();
this.indicators = context.getIndicators();
this.history = context.getHistory();
fetchOutputNames();
IBar currBar = history.getBar(instrument, period, side, 0);
for(Period timePeriod : timePeriods){
double[][] pivot = indicators.pivot(instrument, period, side, timePeriod, Filter.NO_FILTER, barCount, currBar.getTime(), 0);
print("\n============\n"+timePeriod.name() + "\n============\n");
print(String.format("%s", pivotToStr(pivot)));
for(int shift = 0; shift< barCount ;shift++){
double [] pivotDaily = indicators.pivot(instrument, period, side, timePeriod, shift);
print("shift="+shift);
print("pivotDaily " +pivotToStr(pivotDaily));
}
}
}
//...
If you wish to plot the indicator on chart, see:
https://www.dukascopy.com/wiki/#Add_indicators_on_chart/Include_in_OHLC