Hello,
Please see the code attached below. Depending on call order, surprisingly
setFillColor() behaves in different way

Regards,
FXer
package jforex;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IChannelChartObject;
import java.awt.*;
import java.util.UUID;
public class ChannelErrorTest implements IStrategy {
@Configurable(value = "show error")
public boolean showError = true;
@Override
public void onStart(final IContext context) throws JFException {
IChart chart = context.getChart(Instrument.EURUSD);
IHistory history = context.getHistory();
ITick tick = history.getLastTick(Instrument.EURUSD);
long time0 = history.getTimeForNBarsBack(chart.getSelectedPeriod(), tick.getTime(), 10);
long time1 = history.getTimeForNBarsBack(chart.getSelectedPeriod(), tick.getTime(), 2);
long time2 = history.getTimeForNBarsBack(chart.getSelectedPeriod(), tick.getTime(), 6);
double PIP = Instrument.EURUSD.getPipValue();
IChannelChartObject channel = chart.getChartObjectFactory().createChannel(
UUID.randomUUID().toString(),
time0, tick.getBid() + 10 * PIP,
time1, tick.getBid() + 15 * PIP,
time2, tick.getBid() - 5 * PIP);
channel.setFillOpacity((float) 0.5);
if (showError) {
// Here is the glitch!!! Channel fill should be RED but it is GREY :?
channel.setFillColor(Color.RED);
chart.add(channel);
} else {
// It is OK, as expected :)
chart.add(channel);
channel.setFillColor(Color.RED);
}
context.stop();
}
@Override
public void onAccount(IAccount account) throws JFException {
}
@Override
public void onMessage(IMessage message) throws JFException {
}
@Override
public void onStop() throws JFException {
}
@Override
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) {
}
}