I am running a back test that is showing an hourly AUD/USD chart. I have added an alligator indicator to this chart using the following code:
@Override
public void onStart(IContext context) throws JFException
{
super.onStart(context);
...
IChart chart = context.getChart(instrument);
chart.add(context.getIndicators().getIndicator("ALLIGATOR"),
new Object[] { 13, 8, 5 },
new Color[] { Color.blue, Color.red, Color.green },
new DrawingStyle[] {DrawingStyle.LINE, DrawingStyle.LINE, DrawingStyle.LINE },
new int[] { 1, 1, 1} );
...
This works fine except that the price property for the indicator is set to Median Price (HL/2). First question, how do I set it to Close? I have manually changed it for this example.
Now to the main problem. When I process a new bar, I use the following code to retrieve the indicator values:
double[][] alligatorValues = indicators.alligator(feed, AppliedPrice.CLOSE, OfferSide.BID, 13, 8, 5).calculate(2, time, 0);
where time is the bid bar time value. In the calculate call I have used 2 for the bars before parameter because the value 1 doesn't give me the data I need. However, 2 doesn't help me either. This is what the last few bars on the chart look like:
Here is the data from the calculate indicator call:
Notice that the second values in each of the array items of the alligatorValues results are displayed on the right of the chart where the indicator has extended the line to, but when I hover over the line above the bar, it is a different value. The value above the bar is what I need to use, but I can't seem to get this using the calculate call. Could you please help me get the correct values, thanks.