Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

IChart.setFeedDescriptor() incorrectly switches periods
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=55959
Page 1 of 1

Author:  mtnfx [ Fri 15 Dec, 2017, 22:16 ]
Post subject:  IChart.setFeedDescriptor() incorrectly switches periods

Hello,

i'm trying to programmatically change selected period for chart and it does not work correctly.
Title of the chart changes whereas dropdown still shows old period. See screenshot.

Image

Sample strategy to reproduce is below.
Steps to reproduce:
1. Open any chart from "Instruments" and manually select "Period = 1 minute"
2. Click button "Set 4H" button on Strategy's pane

Expected behavior: both title and dropdown should show "4H / 4 Hours" as selected time frame.

package jforex.experimental;

import com.dukascopy.api.*;
import com.dukascopy.api.feed.IFeedDescriptor;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SetPeriodBugDemoStrategy implements IStrategy {
    private IContext context;

    private String myTabTitle = "Set Chart Period Bug";
    private JPanel myTab;

    @Override
    public void onStart(IContext context) throws JFException {
        this.context = context;
        myTab = context.getUserInterface().getLeftTab(myTabTitle);

        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                IChart chart = SetPeriodBugDemoStrategy.this.context.getLastActiveChart();
                IFeedDescriptor fd = chart.getFeedDescriptor();

                fd.setPeriod(Period.FOUR_HOURS);
                chart.setFeedDescriptor(fd);
            }
        };

        JButton button = new JButton("Set 4H");
        button.addActionListener(actionListener);
        myTab.add(button);
    }

    public void onStop() throws JFException {
        context.getUserInterface().removeLeftTab(myTabTitle);
    }

    @Override public void onTick(Instrument instrument, ITick tick) throws JFException {}
    @Override public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
    @Override public void onMessage(IMessage message) throws JFException {}
    @Override public void onAccount(IAccount account) throws JFException {}
}


Attachments:
Set Chart Period.png [12.19 KiB]
Downloaded 298 times

Author:  API Support [ Thu 21 Dec, 2017, 10:54 ]
Post subject:  Re: IChart.setFeedDescriptor() incorrectly switches periods

This has been fixed and will be available with next platform release.

  Page 1 of 1