Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

channel.setFillColor() and chart.add() misbehavior
 Post subject: channel.setFillColor() and chart.add() misbehavior Post rating: 0   New post Posted: Tue 26 Apr, 2016, 23:28 

User rating: 1
Joined: Tue 24 Apr, 2012, 13:41
Posts: 39
Hello,

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

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) {
    }
}


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com