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