Dear Community/Support
What is the recommended method for getting indicator values based on 1HR period, at a smaller period, say 15 minute or 30 minute?
For example if we have an onBar implementation like below, it will calculate the value of linear regression every 1HR bar.
But I would like to get the value of the 1HR period linear regression halfway through the 1HR - at the 30M mark - how can I calculate the value of the 1HR period linear regression every time onBar receives a Period.THIRTY_MINS bar?
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException
{
if (period == Period.ONE_HOUR)
{
try
{
IBar currentBidBar = _history.getBar(instrument, _period, OfferSide.BID, 0);
IBar closedBar = _history.getBar(instrument, _period, OfferSide.BID, 1);
long closedBarTime = _history.getBarStart(_period, closedBar.getTime());
long openedBarTime = currentBidBar.getTime();
// linear regression
Object[] values;
values = indicators.calculateIndicator(instrument,
_period,
new OfferSide[] {OfferSide.BID },
"LINEARREG",
new IIndicators.AppliedPrice[] { IIndicators.AppliedPrice.CLOSE },
new Object[] { _lrPeriod },
Filter.WEEKENDS,
2,
closedBarTime,
0);
double[] lrValues = (double[]) values[0];
double lr = lrValues[1];
double lr1 = lrValues[0];
}
catch (JFException e)
{
e.printStackTrace();
}
}
}